当前位置: 首页 > 知识库问答 >
问题:

Spring boot应用程序在本地tomcat 8上正常启动,但我得到了404

海保臣
2023-03-14

我的spring boot应用程序正常启动,没有任何错误或警告,我在控制台中看到所有URL映射如下所示:

2019-01-25 13:26:56.157 INFO 1020---[ost-startStop-2]S.W.S.M.M.A.RequestMappingHandlerMapping:将“{[/auth/useraccessToken],methods=[POST]}”映射到公共java.lang.string com.test.garmin.controller.oauthController.generateToken(java.lang.long,java.lang.String,org.springframework.ui.model)

我看到初始化已经完成:

2019-01-25 14:25:57.714信息21244---[ost-startStop-1]o.s.web.servlet.dispatcherservlet:FrameworkServlet'measurementrest':初始化在4175毫秒内完成

当我试图使用我的webservices时,我得到的结果是404找不到。

@Configuration
@ComponentScan(basePackages ={"com.test.garmin.controller","com.test.measurement.ws"})
@EntityScan
@EnableAutoConfiguration
public class Application extends SpringBootServletInitializer {

    public static void main(String[] args) {
        SpringApplication.run(applicationClass, args);
    }

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(applicationClass);
    }

    private static Class<Application> applicationClass = Application.class;
}
@RestController
@EnableAutoConfiguration
@RequestMapping(value = "/example")
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context"
       xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd">
    <mvc:annotation-driven/>
    <context:component-scan base-package="com.test.garmin.controller , com.test.measurement.ws" />
</beans>

共有1个答案

麹耘豪
2023-03-14

404个地图找不到。请提供您的客户端正在使用的URL,以及控制器的完整代码。至少所有的方法签名。

 类似资料: