将 Spring Boot 部署到 Wildfly 10
Posted
技术标签:
【中文标题】将 Spring Boot 部署到 Wildfly 10【英文标题】:Deploy Spring Boot to Wildfly 10 【发布时间】:2016-09-08 19:53:46 【问题描述】:有没有人尝试成功地将 springboot 应用程序部署到wildfly 10?我已经找了一些例子,但我只找到了 wildfly 8.2
这是我的应用程序类:
@SpringBootApplication
@EnableEurekaServer
@EnableDiscoveryClient
public class ServereurekaApplication extends SpringBootServletInitializer
public static void main(String[] args)
SpringApplication.run(ServereurekaApplication.class, args);
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application)
return application.sources(ServereurekaApplication.class);
这是我的 POM
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example.servereureka</groupId>
<artifactId>servereureka</artifactId>
<version>1</version>
<packaging>war</packaging>
<name>servereureka</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.3.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Brixton.RC2</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
我总是收到这个错误:
无法上传部署:"WFLYCTL0080: Failed services" => "jboss.undertow.deployment.default-server.default-host.\"/servereureka-0.0.1-SNAPSHOT\"" => "org. jboss.msc.service.StartException 在服务 jboss.undertow.deployment.default-server.default-host.\"/servereureka-0.0.1-SNAPSHOT\": java.lang.RuntimeException: org.springframework.context.ApplicationContextException:无法启动嵌入式容器;嵌套异常是 org.springframework.beans.factory.BeanCreationException:创建名为“org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter”的 bean 时出错:注入自动装配的依赖项失败;嵌套异常是 org .springframework.beans.factory.BeanCreationException:无法自动装配字段:私有 org.springframework.boot.autoconfigure.web.HttpMessageConverters org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter.messageConverters;嵌套异常是 org.springframework。 beans.factory.BeanCreationException:创建名为“org.springframework.boot.autoconfigure.web.HttpMessageConvertersAutoConfiguration”的bean时出错:注入自动装配依赖项失败;嵌套异常是 org.springframework.beans.factory.BeanCreationException:无法自动装配字段:私有最终 java.util.List org.springframework.boot.autoconfigure.web.HttpMessageConvertersAutoConfiguration.converters;嵌套异常是 org.springframework.beans.factory.BeanCreationException:在类路径资源 [org/springframework/boot/autoconfigure/web/JacksonHttpMessageConvertersConfiguration$MappingJackson2XmlHttpMessageConverterConfiguration.class] 中定义名称为“mappingJackson2XmlHttpMessageConverter”的 bean 创建错误:通过工厂方法进行 Bean 实例化失败;嵌套异常是 org.springframework.beans.BeanInstantiationException:无法实例化 [org.springframework.http.converter.xml.MappingJackson2XmlHttpMessageConverter]:工厂方法“mappingJackson2XmlHttpMessageConverter”抛出异常;嵌套异常是 java.lang.NoSuchMethodError: com.fasterxml.jackson.databind.SerializationConfig.withDefaultPrettyPrinter(Lcom/fasterxml/jackson/core/PrettyPrinter;)Lcom/fasterxml/jackson/databind/SerializationConfig;引起:java.lang.RuntimeException: org.springframework.context.ApplicationContextException: 无法启动嵌入式容器;嵌套异常是 org.springframework.beans.factory.BeanCreationException:创建名为 'org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter' 的 bean 时出错:注入自动装配的依赖项失败;嵌套异常是 org.springframework.beans.factory.BeanCreationException:无法自动装配字段:私有 org.springframework.boot.autoconfigure.web.HttpMessageConverters org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter.messageConverters;嵌套异常是 org.springframework.beans.factory.BeanCreationException:创建名为 'org.springframework.boot.autoconfigure.web.HttpMessageConvertersAutoConfiguration' 的 bean 时出错:注入自动装配的依赖项失败;嵌套异常是 org.springframework.beans.factory.BeanCreationException:无法自动装配字段:私有最终 java.util.List org.springframework.boot.autoconfigure.web.HttpMessageConvertersAutoConfiguration.converters;嵌套异常是 org.springframework.beans.factory.BeanCreationException:在类路径资源 [org/springframework/boot/autoconfigure/web/JacksonHttpMessageConvertersConfiguration$MappingJackson2XmlHttpMessageConverterConfiguration.class] 中定义名称为“mappingJackson2XmlHttpMessageConverter”的 bean 创建错误:通过工厂方法进行 Bean 实例化失败;嵌套异常是 org.springframework.beans.BeanInstantiationException:无法实例化 [org.springframework.http.converter.xml.MappingJackson2XmlHttpMessageConverter]:工厂方法“mappingJackson2XmlHttpMessageConverter”抛出异常;嵌套异常是 java.lang.NoSuchMethodError: com.fasterxml.jackson.databind.SerializationConfig.withDefaultPrettyPrinter(Lcom/fasterxml/jackson/core/PrettyPrinter;)Lcom/fasterxml/jackson/databind/SerializationConfig;引起:org.springframework.context.ApplicationContextException:无法启动嵌入式容器;嵌套异常是 org.springframework.beans.factory.BeanCreationException:创建名为 'org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter' 的 bean 时出错:注入自动装配的依赖项失败;嵌套异常是 org.springframework.beans.factory.BeanCreationException:无法自动装配字段:私有 org.springframework.boot.autoconfigure.web.HttpMessageConverters org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter.messageConverters;嵌套异常是 org.springframework.beans.factory.BeanCreationException:创建名为 'org.springframework.boot.autoconfigure.web.HttpMessageConvertersAutoConfiguration' 的 bean 时出错:注入自动装配的依赖项失败;嵌套异常是 org.springframework.beans.factory.BeanCreationException:无法自动装配字段:私有最终 java.util.List org.springframework.boot.autoconfigure.web.HttpMessageConvertersAutoConfiguration.converters;嵌套异常是 org.springframework.beans.factory.BeanCreationException:在类路径资源 [org/springframework/boot/autoconfigure/web/JacksonHttpMessageConvertersConfiguration$MappingJackson2XmlHttpMessageConverterConfiguration.class] 中定义名称为“mappingJackson2XmlHttpMessageConverter”的 bean 创建错误:通过工厂方法进行 Bean 实例化失败;嵌套异常是 org.springframework.beans.BeanInstantiationException:无法实例化 [org.springframework.http.converter.xml.MappingJackson2XmlHttpMessageConverter]:工厂方法“mappingJackson2XmlHttpMessageConverter”抛出异常;嵌套异常是 java.lang.NoSuchMethodError: com.fasterxml.jackson.databind.SerializationConfig.withDefaultPrettyPrinter(Lcom/fasterxml/jackson/core/PrettyPrinter;)Lcom/fasterxml/jackson/databind/SerializationConfig;原因:org.springframework.beans.factory.BeanCreationException:创建名为“org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter”的bean时出错:注入自动装配的依赖项失败;嵌套异常是 org.springframework.beans.factory.BeanCreationException:无法自动装配字段:私有 org.springframework.boot.autoconfigure.web.HttpMessageConverters org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter.messageConverters;嵌套异常是 org.springframework.beans.factory.BeanCreationException:创建名为 'org.springframework.boot.autoconfigure.web.HttpMessageConvertersAutoConfiguration' 的 bean 时出错:注入自动装配的依赖项失败;嵌套异常是 org.springframework.beans.factory.BeanCreationException:无法自动装配字段:私有最终 java.util.List org.springframework.boot.autoconfigure.web.HttpMessageConvertersAutoConfiguration.converters;嵌套异常是 org.springframework.beans.factory.BeanCreationException:在类路径资源 [org/springframework/boot/autoconfigure/web/JacksonHttpMessageConvertersConfiguration$MappingJackson2XmlHttpMessageConverterConfiguration.class] 中定义名称为“mappingJackson2XmlHttpMessageConverter”的 bean 创建错误:通过工厂方法进行 Bean 实例化失败;嵌套异常是 org.springframework.beans.BeanInstantiationException:无法实例化 [org.springframework.http.converter.xml.MappingJackson2XmlHttpMessageConverter]:工厂方法“mappingJackson2XmlHttpMessageConverter”抛出异常;嵌套异常是 java.lang.NoSuchMethodError: com.fasterxml.jackson.databind.SerializationConfig.withDefaultPrettyPrinter(Lcom/fasterxml/jackson/core/PrettyPrinter;)Lcom/fasterxml/jackson/databind/SerializationConfig;引起:org.springframework.beans.factory.BeanCreationException:无法自动装配字段:私有 org.springframework.boot.autoconfigure.web.HttpMessageConverters org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter.messageConverters;嵌套异常是 org.springframework.beans.factory.BeanCreationException:创建名为 'org.springframework.boot.autoconfigure.web.HttpMessageConvertersAutoConfiguration' 的 bean 时出错:注入自动装配的依赖项失败;嵌套异常是 org.springframework.beans.factory.BeanCreationException:无法自动装配字段:私有最终 java.util.List org.springframework.boot.autoconfigure.web.HttpMessageConvertersAutoConfiguration.converters;嵌套异常是 org.springframework.beans.factory.BeanCreationException:在类路径资源 [org/springframework/boot/autoconfigure/web/JacksonHttpMessageConvertersConfiguration$MappingJackson2XmlHttpMessageConverterConfiguration.class] 中定义名称为“mappingJackson2XmlHttpMessageConverter”的 bean 创建错误:通过工厂方法进行 Bean 实例化失败;嵌套异常是 org.springframework.beans.BeanInstantiationException:无法实例化 [org.springframework.http.converter.xml.MappingJackson2XmlHttpMessageConverter]:工厂方法“mappingJackson2XmlHttpMessageConverter”抛出异常;嵌套异常是 java.lang.NoSuchMethodError: com.fasterxml.jackson.databind.SerializationConfig.withDefaultPrettyPrinter(Lcom/fasterxml/jackson/core/PrettyPrinter;)Lcom/fasterxml/jackson/databind/SerializationConfig;原因:org.springframework.beans.factory.BeanCreationException:创建名为“org.springframework.boot.autoconfigure.web.HttpMessageConvertersAutoConfiguration”的bean时出错:注入自动装配依赖项失败;嵌套异常是 org.springframework.beans.factory.BeanCreationException:无法自动装配字段:私有最终 java.util.List org.springframework.boot.autoconfigure.web.HttpMessageConvertersAutoConfiguration.converters;嵌套异常是 org.springframework.beans.factory.BeanCreationException:在类路径资源 [org/springframework/boot/autoconfigure/web/JacksonHttpMessageConvertersConfiguration$MappingJackson2XmlHttpMessageConverterConfiguration.class] 中定义名称为“mappingJackson2XmlHttpMessageConverter”的 bean 创建错误:通过工厂方法进行 Bean 实例化失败;嵌套异常是 org.springframework.beans.BeanInstantiationException:无法实例化 [org.springframework.http.converter.xml.MappingJackson2XmlHttpMessageConverter]:工厂方法“mappingJackson2XmlHttpMessageConverter”抛出异常;嵌套异常是 java.lang.NoSuchMethodError: com.fasterxml.jackson.databind.SerializationConfig.withDefaultPrettyPrinter(Lcom/fasterxml/jackson/core/PrettyPrinter;)Lcom/fasterxml/jackson/databind/SerializationConfig;引起:org.springframework.beans.factory.BeanCreationException:无法自动装配字段:私有最终java.util.List org.springframework.boot.autoconfigure.web.HttpMessageConvertersAutoConfiguration.converters;嵌套异常是 org.springframework.beans.factory.BeanCreationException:在类路径资源 [org/springframework/boot/autoconfigure/web/JacksonHttpMessageConvertersConfiguration$MappingJackson2XmlHttpMessageConverterConfiguration.class] 中定义名称为“mappingJackson2XmlHttpMessageConverter”的 bean 创建错误:通过工厂方法进行 Bean 实例化失败;嵌套异常是 org.springframework.beans.BeanInstantiationException:无法实例化 [org.springframework.http.converter.xml.MappingJackson2XmlHttpMessageConverter]:工厂方法“mappingJackson2XmlHttpMessageConverter”抛出异常;嵌套异常是 java.lang.NoSuchMethodError: com.fasterxml.jackson.databind.SerializationConfig.withDefaultPrettyPrinter(Lcom/fasterxml/jackson/core/PrettyPrinter;)Lcom/fasterxml/jackson/databind/SerializationConfig;引起:org.springframework.beans.factory.BeanCreationException:在类路径资源[org/springframework/boot/autoconfigure/web/JacksonHttpMessageConvertersConfiguration$MappingJackson2XmlHttpMessageConverterConfiguration.class]中定义的名称为“mappingJackson2XmlHttpMessageConverter”的bean创建错误:通过工厂方法进行的bean实例化失败;嵌套异常是 org.springframework.beans.BeanInstantiationException:无法实例化 [org.springframework.http.converter.xml.MappingJackson2XmlHttpMessageConverter]:工厂方法“mappingJackson2XmlHttpMessageConverter”抛出异常;嵌套异常是 java.lang.NoSuchMethodError: com.fasterxml.jackson.databind.SerializationConfig.withDefaultPrettyPrinter(Lcom/fasterxml/jackson/core/PrettyPrinter;)Lcom/fasterxml/jackson/databind/SerializationConfig;原因:org.springframework.beans.BeanInstantiationException:无法实例化[org.springframework.http.converter.xml.MappingJackson2XmlHttpMessageConverter]:工厂方法'mappingJackson2XmlHttpMessageConverter'抛出异常;嵌套异常是 java.lang.NoSuchMethodError: com.fasterxml.jackson.databind.SerializationConfig.withDefaultPrettyPrinter(Lcom/fasterxml/jackson/core/PrettyPrinter;)Lcom/fasterxml/jackson/databind/SerializationConfig;引起:java.lang.NoSuchMethodError: com.fasterxml.jackson.databind.SerializationConfig.withDefaultPrettyPrinter(Lcom/fasterxml/jackson/core/PrettyPrinter;)Lcom/fasterxml/jackson/databind/SerializationConfig;"
【问题讨论】:
【参考方案1】:Exclude jaxrs subsystem using jboss-deployment-structure.xml
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
<deployment>
<exclude-subsystems>
<subsystem name="jaxrs" />
</exclude-subsystems>
</deployment>
</jboss-deployment-structure>
【讨论】:
谢谢它的工作,我只需将该文件添加到 webapp\WEB-INF【参考方案2】:您在 pom.xml 中的依赖项需要是这样的:
<dependencies>
<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>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
</dependency>
</dependencies>
并在 Application.java 文件中扩展 SpringBootServletInitializer:
@SpringBootApplication
public class Application extends SpringBootServletInitializer
public static void main(String[] args)
SpringApplication.run(Application.class);
你基本上没有 我希望这会有所帮助
【讨论】:
以上是关于将 Spring Boot 部署到 Wildfly 10的主要内容,如果未能解决你的问题,请参考以下文章
Spring Boot 2 重新部署到 Wildfly 10 后无法刷新 JMS 连接
Spring Boot 应用程序未部署在 Wildfly 上
在 Wildfly 中部署的 Spring Boot 应用程序“无法实例化 WebApplicationInitializer 类”