就像通常的微服务打包部署至国产化环境中一样,先是做了以下操作:
- 排除默认的Tomcat
- 打war包
- 重写启动类
可是 war 打包时报错:
- 找不到javax.servlet.Filter的类文件;
- Description:The Bean Validation API is on the classpath but no implementation could be found; Action:Add an implementation, such as Hibernate Validator, to the classpath
打war包org.springframework.boot spring-boot-starter-web org.springframework.boot spring-boot-starter-tomcat
重写启动类war ${project.artifactId} maven-war-plugin 2.6 false
重写启动类,继承 SpringBootServletInitializer 类,重写 configure 方法,否则无法检测到启动类。
public class StandardMonitorApplication extends SpringBootServletInitializer
{
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
return builder.sources(StandardMonitorApplication.class);
}
public static void main(String[] args)
{
SpringApplication.run(StandardMonitorApplication.class, args);
System.out.println("(♥◠‿◠)ノ゙ 系统模块启动成功 ლ(´ڡ`ლ)゙ ");
}
}
解决错误1:
由于使用TongWeb,在 pom 文件中排除了 Tomcat ,代码中用到了WebSecurityConfigurerAdapter,打包报错:找不到 javax.servlet.Filter 的类文件
- 添加依赖:javaee-api
解决错误2:javax javaee-api 7.0
Description:
The Bean Validation API is on the classpath but no implementation could be found
Action:
Add an implementation, such as Hibernate Validator, to the classpath
- 添加依赖:hibernate-validator
org.hibernate hibernate-validator 5.2.4.Final
If you have any questions or any bugs are found, please feel free to contact me.
Your comments and suggestions are welcome!



