-1

尝试将 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 时出现错误。

引用类 io/undertow/UndertowOptions 的类加载器(org/jboss/modules/ModuleClassLoader 的实例)和字段解析类型 org/xnio/ 的类加载器(org/jboss/modules/ModuleClassLoader 的实例)选项,该类型有不同的类对象[错误] 原因:org.springframework.beans.factory.BeanCreationException:创建类路径资源中定义的名称为“undertowServletWebServerFactory”的bean时出错[org/springframework/boot/autoconfigure/web/servlet /ServletWebServerFactoryConfiguration$EmbeddedUndertow.class]:bean 初始化失败;嵌套异常是 java.lang.LinkageError:加载器约束违规:当解析字段“MAX_HEADER_SIZE”时,引用类 io/undertow/UndertowOptions 的类加载器(org/jboss/modules/ModuleClassLoader 的实例),

据我了解,原因是依赖关系。如何解决?

4

1 回答 1

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>
于 2020-07-16T13:27:47.803 回答