尝试将Spring Boot应用程序部署到wildfly。这是我的pom.xml
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.1.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>pro.profsoft</groupId>
<artifactId>admin</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>admin</name>
<description>administration panel</description>
<properties>
<java.version>1.8</java.version>
<vaadin.version>14.2.3</vaadin.version>
<junit.jupiter.version>5.7.0-M1</junit.jupiter.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<wildfly-hostname>localhost</wildfly-hostname>
<wildfly-port>9990</wildfly-port>
<wildfly-username>wildfly</wildfly-username>
<wildfly-password>wildfly</wildfly-password>
</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-security</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>com.vaadin</groupId>
<artifactId>vaadin-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<scope>runtime</scope>
</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>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
<exclusion>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>${junit.jupiter.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.wildfly.plugins/wildfly-maven-plugin -->
<dependency>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-maven-plugin</artifactId>
<version>2.0.2.Final</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.reactivestreams/reactive-streams -->
<dependency>
<groupId>org.reactivestreams</groupId>
<artifactId>reactive-streams</artifactId>
<version>1.0.3</version>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-bom</artifactId>
<version>${vaadin.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<finalName>${project.name}</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-maven-plugin</artifactId>
<version>2.0.2.Final</version>
<configuration>
<hostname>${wildfly-hostname}</hostname>
<port>${wildfly-port}</port>
<username>${wildfly-username}</username>
<password>${wildfly-password}</password>
<name>${project.name}.war</name>
</configuration>
</plugin>
<plugin>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-maven-plugin</artifactId>
<version>${vaadin.version}</version>
<executions>
<execution>
<goals>
<goal>prepare-frontend</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
当我启动mvn wildfly:deploy时遇到错误。
[错误]无法在项目admin上执行目标org.wildfly.plugins:wildfly-maven-plugin:2.0.2.Final:deploy(default-cli):无法执行目标部署:{“ WFLYCTL0062:复合操作失败并回滚失败的步骤:“ => {”操作步骤1“ => {” WFLYCTL0080:服务失败“ => {” jboss.deployment.unit。“ admin.war” .undertow-deployment“ = >“ java.lang.RuntimeException:org.springframework.beans.factory.BeanCreationException:在类路径资源[org / springframework / boot / autoconfigure / web / servlet / ServletWebServerFactoryConfiguration $ EmbeddedUndertow.class]中创建名称为'undertowServletWebServerFactory'的bean时出错:初始化Bean失败;嵌套异常是java.lang.LinkageError:违反了加载器约束:在解析字段“ MAX_HEADER_SIZE”时,引用类io / undertow / UndertowOptions的类加载器(org / jboss / modules / ModuleClassLoader的实例)和fi的类加载器(org / jboss / modules / ModuleClassLoader的实例)字段的解析类型org / xnio / Option具有不同的Class对象 [错误]原因:java.lang.RuntimeException:org.springframework.beans.factory.BeanCreationException:创建类路径资源[org / springframework / boot / autoconfigure / web / servlet / ServletWebServerFactoryConfiguration $中定义的名称为'undertowServletWebServerFactory'的bean时出错[EmbeddedUndertow.class]:Bean初始化失败;嵌套的异常是java.lang.LinkageError:违反加载器约束:解析字段“ MAX_HEADER_SIZE”时,引用类io / undertow / UndertowOptions的类加载器(org / jboss / modules / ModuleClassLoader的实例)和类加载器(实例字段的解析类型org / xnio / Option的org / jboss / modules / ModuleClassLoader属性)具有该类型的不同Class对象 [错误]原因:org.springframework.beans.factory.BeanCreationException:在类路径资源[org / springframework / boot / autoconfigure / web / servlet / ServletWebServerFactoryConfiguration $ EmbeddedUndertow.class]中创建名称为“ undertowServletWebServerFactory”的bean时出错。豆失败;嵌套的异常是java.lang.LinkageError:违反加载器约束:解析字段“ MAX_HEADER_SIZE”时,引用类io / undertow / UndertowOptions的类加载器(org / jboss / modules / ModuleClassLoader的实例)和类加载器(实例字段的解析类型org / xnio / Option的org / jboss / modules / ModuleClassLoader属性)具有该类型的不同Class对象 [错误]原因:java.lang.LinkageError:违反加载程序约束:在解析字段“ MAX_HEADER_SIZE”时,引用类io / undertow / UndertowOptions的类加载器(org / jboss / modules / ModuleClassLoader的实例)字段的解析类型org / xnio / Option的loader(实例为org / jboss / modules / ModuleClassLoader的实例)对于该类型具有不同的Class对象”}}}}
据我了解,原因是依赖关系。如何解决?
答案 0 :(得分:0)
原来是与插件提取的库有冲突
<dependency>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-maven-plugin</artifactId>
<version>2.0.2.Final</version>
<exclusions>
<exclusion>
<groupId>org.jboss.xnio</groupId>
<artifactId>xnio-api</artifactId>
</exclusion>
</exclusions>
</dependency>