将Spring引导战争与其他战争

时间:2017-06-01 10:24:26

标签: java spring-boot war ear wildfly-8

我使用spring boot创建了zuul代理应用程序,我可以通过在pom和SpringApplication类文件中进行一些更改,将它部署为Wildfly服务器中的spring boot和war。

我的耳朵结构:

  MyEE.ear
  |
  |__gatewayzull.war
        |_WEB-INF/lib/all jar for spring boot application
  |
  |__EJB.jar
  |
  |__XX.war
  |
  |lib/all jar (which also includes spring jars)

我在pom.xml中做了一些更改,以便在WildFly服务器中部署spring应用程序war并且它正在按预期工作。

当我尝试在MyEE.ear中添加gatewayzull.war并将其部署在Wildfly服务器中时,我收到此异常

10:08:47,108 INFO  [com.hummingbird.gateway.HbgatewayApplication] (MSC service thread 1-4) No active profile set, falling back to default profiles: default
10:08:47,119 INFO  [org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext] (MSC service thread 1-4) Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@51640e39: startup date [Thu Jun 01 10:08:47 UTC 2017]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@50b75933
....
....
....
....
10:08:56,635 WARN  [org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext] (MSC service thread 1-4) Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanDefinitionStoreException: Failed to process import candidates for configuration class [org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration$TransactionManagementConfiguration]; nested exception is java.lang.IllegalArgumentException: class org.springframework.transaction.annotation.TransactionManagementConfigurationSelector is not assignable to interface org.springframework.context.annotation.ImportSelector
10:08:56,711 ERROR [org.springframework.boot.SpringApplication] (MSC service thread 1-4) Application startup failed: org.springframework.beans.factory.BeanDefinitionStoreException: Failed to process import candidates for configuration class [org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration$TransactionManagementConfiguration]; nested exception is java.lang.IllegalArgumentException: class org.springframework.transaction.annotation.TransactionManagementConfigurationSelector is not assignable to interface org.springframework.context.annotation.ImportSelector
    at org.springframework.context.annotation.ConfigurationClassParser.processImports(ConfigurationClassParser.java:546) [spring-context-4.3.2.RELEASE.jar:4.3.2.RELEASE]
    at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:286) [spring-context-4.3.2.RELEASE.jar:4.3.2.RELEASE]
.....
.....
.....
Caused by: java.lang.IllegalArgumentException: class org.springframework.transaction.annotation.TransactionManagementConfigurationSelector is not assignable to interface org.springframework.context.annotation.ImportSelector
    at org.springframework.util.Assert.isAssignable(Assert.java:376) [spring-core-4.3.2.RELEASE.jar:4.3.2.RELEASE]
    at org.springframework.util.Assert.isAssignable(Assert.java:359) [spring-core-4.3.2.RELEASE.jar:4.3.2.RELEASE]
    at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:124) [spring-beans-4.3.2.RELEASE.jar:4.3.2.RELEASE]
    at org.springframework.context.annotation.ConfigurationClassParser.processImports(ConfigurationClassParser.java:511) [spring-context-4.3.2.RELEASE.jar:4.3.2.RELEASE]
    ... 30 more

WildFly试图启动Gatewayapplication但未能启动它。

未加载gatewayzull.war.WEB-INF.lib中的jar。 deployment.MyEE.ear.lib也有spring相关的jar。我在jboss-deplyment-structure.xml中添加了排除标记,以便在加载时排除,但这也没有帮助。

jboss.xml的snipper:

<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
        ..
        ..
        <sub-deployment name="gateway.war">
        <exclusions>
            <module name="deployment.MyEE.ear.XX.war" />
            <module name="deployment.MyEE.ear.EJB.jar" />
            <module name="deployment.MyEE.ear.lib" />
            <module name="javax.ws.rs.api" />
        </exclusions>
        <exclude-subsystems>
            <subsystem name="jaxrs" />
        </exclude-subsystems>
    </sub-deployment>
</jboss-deployment-structure>

我假设核心问题是由于应用服务器无法在war / web-inf / lib中加载jar,反过来服务器不能初始化SpringBootServeletIntializer。

有什么想法解决这个问题吗?

0 个答案:

没有答案