Ank*_*kit 3 java jboss spring spring-boot jboss-eap-7
我无法在JBOSS EAP 7服务器上部署我的Spring BOOT REST应用程序。
但是,在Apache Tomcat 8服务器上部署后,它运行良好。
应用主类:
@SpringBootApplication(scanBasePackages= {"org.nic"})
@PropertySource(value="classpath:database.properties")
public class PopulationApplication extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(PopulationApplication.class);
}
public static void main(String[] args) throws Exception {
SpringApplication.run(PopulationApplication.class, args);
}
}
Run Code Online (Sandbox Code Playgroud)
pom.xml
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.2.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<start-class>org.nic.PopulationApplication</start-class>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<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>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
</dependency>
<!-- <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency> -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
Run Code Online (Sandbox Code Playgroud)
它在服务器日志上引发以下错误
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.web.servlet.filter.OrderedHttpPutFormContentFilter]: Factory method 'httpPutFormContentFilter' threw exception; nested exception is java.lang.VerifyError: Failed to link com/fasterxml/jackson/databind/type/ReferenceType (Module "deployment.nhpmapi-0.0.1-SNAPSHOT.war:main" from Service Module Loader): Cannot inherit from final class
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:579)
... 35 more
Run Code Online (Sandbox Code Playgroud)
我的服务器环境只有JBOSS EAP 7。
我已经进行了研究来解决此问题,但未成功。
我最后一个选择是将Spring BOOT配置删除,以便在JBOSS EAP 7上运行
我遇到了同样的问题,挣扎了两天。终于找到了解决方案!
java.lang.VerifyError通常是在类不一致时引起的。
如错误消息中所示,这是com.fasterxml.jackson.core.jackson-databind
由于Jboss具有其内部Jackson模块,并且其版本与您指定的应用程序不同而引起的。
要解决该问题,请将jboss-deployment-structure.xml其添加到下面src/main/webapp/WEB-INF:
<?xml version='1.0' encoding='UTF-8'?>
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.1">
<deployment>
<exclusions>
<module name="com.fasterxml.jackson.core.jackson-annotations" />
<module name="com.fasterxml.jackson.core.jackson-core" />
<module name="com.fasterxml.jackson.core.jackson-databind" />
<module name="com.fasterxml.jackson.datatype.jackson-datatype-jdk8"/>
<module name="com.fasterxml.jackson.datatype.jackson-datatype-jsr310"/>
<module name="com.fasterxml.jackson.jaxrs.jackson-jaxrs-json-provider" />
<module name="org.jboss.resteasy.resteasy-jackson2-provider" />
<module name="org.slf4j" />
</exclusions>
</deployment>
</jboss-deployment-structure>
Run Code Online (Sandbox Code Playgroud)
它将避免隐式依赖并解决问题。
在这里,这里和这里找到答案,谢谢他们!
有关更多信息:
获得java.lang.VerifyError的原因
什么是jboss-deployment-structure.xml
模块依赖项
| 归档时间: |
|
| 查看次数: |
2820 次 |
| 最近记录: |