Spring 升级到 spring boot 2.6.6 后引导应用程序给出 404
Spring Boot Application giving 404 after upgrading to springboot 2.6.6
我已将 Web 应用程序的 spring 引导版本从 2.1.2 更改为 2.6.6。这是 POM---
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.6.6</version>
<relativePath>/</relativePath> <!-- lookup parent from repository -->
</parent>
A1 版本升级后,我遇到了一些循环依赖问题,我使用带有 @Lazy 注释的构造函数注入解决了这些问题。下面是例子---
@Autowired
public CallBackCycleRepositoryServiceImpl(@Lazy CampaignService campaignService,
@Lazy CallBackCycleRepositoryService callBackCycleRepositoryService,
@Lazy CallBackCycleRepositoryMapper callBackCycleRepositoryMapper,
@Lazy CallReasonsRepositoryService callReasonsRepositoryService) {
super();
this.campaignService = campaignService;
this.callBackCycleRepositoryService = callBackCycleRepositoryService;
this.callBackCycleRepositoryMapper = callBackCycleRepositoryMapper;
this.callReasonsRepositoryService = callReasonsRepositoryService;
}
现在我的日志文件显示应用程序已启动。
但是如果我试图打任何 API 它就会给我 404。
任何人都可以建议我如何解决这个问题。
我的控制器就像--
日志中有信息exposing one endpoint beneath base path '/internal'
也许您尝试使用的那些控制器未创建,也许包未被扫描
我在查看所有发布文档后发现了这个问题,我发现 spring-boot 禁用了 default-dispatcher-servlet。所以我们需要用 属性-
启用它
server.servlet.register-default-servlet=true
这个解决方案对我有用。
我已将 Web 应用程序的 spring 引导版本从 2.1.2 更改为 2.6.6。这是 POM---
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.6.6</version>
<relativePath>/</relativePath> <!-- lookup parent from repository -->
</parent>
A1 版本升级后,我遇到了一些循环依赖问题,我使用带有 @Lazy 注释的构造函数注入解决了这些问题。下面是例子---
@Autowired
public CallBackCycleRepositoryServiceImpl(@Lazy CampaignService campaignService,
@Lazy CallBackCycleRepositoryService callBackCycleRepositoryService,
@Lazy CallBackCycleRepositoryMapper callBackCycleRepositoryMapper,
@Lazy CallReasonsRepositoryService callReasonsRepositoryService) {
super();
this.campaignService = campaignService;
this.callBackCycleRepositoryService = callBackCycleRepositoryService;
this.callBackCycleRepositoryMapper = callBackCycleRepositoryMapper;
this.callReasonsRepositoryService = callReasonsRepositoryService;
}
现在我的日志文件显示应用程序已启动。
但是如果我试图打任何 API 它就会给我 404。
任何人都可以建议我如何解决这个问题。
我的控制器就像--
日志中有信息exposing one endpoint beneath base path '/internal'
也许您尝试使用的那些控制器未创建,也许包未被扫描
我在查看所有发布文档后发现了这个问题,我发现 spring-boot 禁用了 default-dispatcher-servlet。所以我们需要用 属性-
启用它server.servlet.register-default-servlet=true
这个解决方案对我有用。