我想在tomcat上运行我的应用程序,所以我更新了一些代码 在pom.xml中,将jar更改为war并排除嵌入式tomcat并添加servlet-api。
<packaging>war</packaging>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<scope>provided</scope>
</dependency>
扩展SpringBootServletInitializer
@SpringBootApplication
public class AppApplication extends SpringBootServletInitializer {
public static void main(String[] args) {
SpringApplication.run(AppApplication.class, args);
}
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(AppApplication.class).web(true);
}
}
然后我收到了这个错误
javax.naming.NameNotFoundException: Name
[xxx.xxx.xxx.CustomerFilterSecurityInterceptor/customerInvocationSecurityMetadataSource]
is not bound in this Context. Unable to find [xxx.xxx.xxx.filter.CustomerFilterSecurityInterceptor].
首先,我认为它可能是tomcat版本的问题,所以我将tomcat更新为8.5.12,并且它不起作用。
顺便说一句:当我打包一个jar文件时,它很好,我使用jdk1.8,并使用spring boot 1.4.1.RELEASE