我无法在JBOSS EAP 7服务器上部署我的Spring BOOT REST应用程序.
但是,它在Apache Tomcat 8 Server上部署后运行正常.
申请主类:
@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);
}
}
的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>
它在服务器日志中抛出以下错误
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
我的服务器环境只有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>
它将避免隐式依赖并解决问题.
感谢他们找到答案here和here和here!
有关更多信息:Causes of getting a java.lang.VerifyError
What is jboss-deployment-structure.xml
Module Dependencies