Spring Boot外置WAR包东方通TongWeb部署问题
使用东方通7.0.3.0部署Spring Boot项目,首先打成war包一、排除内置 Tomcat<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId><!-- 去除内嵌tomcat
使用东方通7.0.3.0部署Spring Boot项目,首先打成war包
一、排除内置 Tomcat
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<!-- 去除内嵌tomcat -->
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
二、将打包方式更改为 war
<packaging>war</packaging>
三、修改启动类
使启动类继承 SpringBootServletInitializer 类,并重写 configure 方法
@SpringBootApplication
public class DemoApplication extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
return builder.sources(DemoApplication.class);
}
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
}
四、东方通部署问题
1、使用Tomcat部署没有问题,但是在TongaWeb下出现java.lang.NoSuchMethodError:javax.validation.spi.ConfigurationState.getValueExtractors()Ljava/util/Set;
Caused by: java.lang.ClassNotFoundException: javax.validation.ParameterNameProvider
因为tomcat不带javax.validation,而TongWeb带javax.validation,使用版本不一致导致。
解决方式:把TongWeb安装目录lib下的validation-api删除替换为应用中的validation-api,我的是validation-api-2.0.1.Final.jar
2、一个容器中部署多个应用出现
Caused by: org.springframework.jmx.export.UnableToRegisterMBeanException: Unable to register MBean [org.springframework.cloud.context.environment.EnvironmentManager@3ebe27fc] with key 'environmentManager'; nested exception is javax.management.InstanceAlreadyExistsException: org.springframework.cloud.context.environment:name=environmentManager,type=EnvironmentManager
原因:spring.jmx是默认打开的,所以有两种解决办法
办法1:spring.jmx.enabled=false
办法2:在application中各自配置
spring.jmx.default-domain=project1
spring.jmx.default-domain=project2
以保证domain是两个不一样的
更多推荐
所有评论(0)