Springboot Wildfly 10.0 War文件部署--->无法实例化WebApplicationInitializer类

时间:2018-03-21 14:10:59

标签: scala spring-mvc spring-boot wildfly-10

我使用scala Rest api创建了spring boot,它正在使用带有jar文件的tomcat(默认服务器)。现在我想部署到Jboss / Wildfly 10.0并创建war文件。在部署期间,我遇到了以下问题。可以帮助解决这个问题。

POM文件:

@RequestMapping(value = {"/messages/list"}, method = RequestMethod.GET)
public String viewMessageLogs(ModelMap model) 
{
    return "messageLogs";
}
部署时

错误消息:

<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.aexp.prospect</groupId>
    <artifactId>atules</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>war</packaging>

    <!--packaging>jar</packaging -->

    <name>atules</name>
    <url>http://maven.apache.org</url>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.2.RELEASE</version>
        <relativePath />
        <!-- lookup parent from repository -->
    </parent>

    <!-- properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
        </properties -->

    <properties>
        <start-class>com.aexp.prospect.atules.AtulApplication</start-class>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
    </properties>

    <!-- dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> 
        <version>3.8.1</version> <scope>test</scope> </dependency> </dependencies -->

    <dependencies>

        <!-- Additional for war files -->
        <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>junit</groupId>
            <artifactId>junit</artifactId>
        </dependency>

        <!-- 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-aop</artifactId> 
            </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-thymeleaf</artifactId> 
            </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-validation</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-test</artifactId> 
            <scope>test</scope> </dependency> <dependency> <groupId>io.springfox</groupId> 
            <artifactId>springfox-swagger2</artifactId> <version>2.4.0</version> </dependency> 
            <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger-ui</artifactId> 
            <version>2.4.0</version> </dependency -->

        <!-- dependency> <groupId>org.scala-lang</groupId> <artifactId>scala-library</artifactId> 
            <version>2.11.8</version> </dependency -->
        <!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient -->
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <version>4.5.5</version><!--$NO-MVN-MAN-VER$ -->
        </dependency>
        <!-- https://mvnrepository.com/artifact/log4j/log4j -->
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.17</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/net.liftweb/lift-json -->
        <dependency>
            <groupId>net.liftweb</groupId>
            <artifactId>lift-json_2.11</artifactId>
            <version>2.6.3</version>
        </dependency>

        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <scope>runtime</scope>
        </dependency>
        <!-- Additional for war files -->

        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <scope>provided</scope>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.springframework/spring-core -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
        </dependency>


    </dependencies>
    <build>
        <finalName>SpringBootES</finalName>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

    <!-- build> <plugins> <plugin> <groupId>net.alchim31.maven</groupId> <artifactId>scala-maven-plugin</artifactId> 
        <version>3.1.3</version> <executions> <execution> <goals> <goal>compile</goal> 
        <goal>testCompile</goal> </goals> </execution> </executions> </plugin> <plugin> 
        <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> 
        </plugin> </plugins> </build -->

</project>

1 个答案:

答案 0 :(得分:0)

问题在于POM文件,我修复了它。下面是我使用的POM文件。特别是start-class,spring-boot-maven-plugin和servlet(最初我开发了Application,它应该转换成servlet)。我最初的POM文件中没有这些。还应该在Jboss / Wildfly 10.0中排除tomcat作为此部署

http://maven.apache.org/xsd/maven-4.0.0.xsd">     4.0.0

<groupId>com.aexp.xxx</groupId>
<artifactId>xxxes</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>

<name>xxxes</name>
<url>http://maven.apache.org</url>

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.5.2.RELEASE</version>
    <relativePath />
    <!-- lookup parent from repository -->
</parent>

<properties>
    <start-class>com.aexp.xxx.xxxes.<Application Class Name></start-class>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <java.version>1.8</java.version>
</properties>

<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>junit</groupId>
        <artifactId>junit</artifactId>
    </dependency>


    <!-- https://mvnrepository.com/artifact/log4j/log4j -->
    <dependency>
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
        <version>1.2.17</version>
    </dependency>

    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>javax.servlet-api</artifactId>
        <scope>provided</scope>
    </dependency>

</dependencies>
<build>
    <finalName>SpringBootES</finalName>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>