无法在war文件的类文件中创建struts.xml文件

时间:2019-04-11 03:16:34

标签: java struts2

我将struts2项目转换为maven struts2项目。在构建war文件时进行转换后,类文件中缺少struts.xml文件。这是为什么?

我已经在src文件夹中添加了我的struts.xml文件,在配置项目时,是否有需要添加它的适当位置?

这是我的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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.epic</groupId>
<artifactId>DF_CMS_DEBIT_REPORT</artifactId>
<version>1.0-SNAPSHOT</version>
    <packaging>war</packaging>
<name>DF_CMS_DEBIT_REPORT</name>

<properties>
    <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>    
    <dependency>
        <groupId>javax</groupId>
        <artifactId>javaee-web-api</artifactId>
        <version>7.0</version>
        <scope>provided</scope>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.antlr/antlr4 -->
    <dependency>
        <groupId>org.antlr</groupId>
        <artifactId>antlr4</artifactId>
        <version>4.7.2</version>
    </dependency>    

    <!-- https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api -->
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>javax.servlet-api</artifactId>
        <version>3.0.1</version>
        <scope>provided</scope>
    </dependency>

    <!-- https://mvnrepository.com/artifact/org.apache.struts/struts2-core -->
    <dependency>
        <groupId>org.apache.struts</groupId>
        <artifactId>struts2-core</artifactId>
        <version>2.3.3</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/org.apache.struts/struts2-dojo-plugin -->
    <dependency>
        <groupId>org.apache.struts</groupId>
        <artifactId>struts2-dojo-plugin</artifactId>
        <version>2.3.3</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/org.apache.struts/struts2-jasperreports-plugin -->
    <dependency>
        <groupId>org.apache.struts</groupId>
        <artifactId>struts2-jasperreports-plugin</artifactId>
        <version>2.3.8</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/com.jgeppert.struts2.jquery/struts2-jquery-chart-plugin -->
    <dependency>
        <groupId>com.jgeppert.struts2.jquery</groupId>
        <artifactId>struts2-jquery-chart-plugin</artifactId>
        <version>3.4.0</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/com.jgeppert.struts2.jquery/struts2-jquery-grid-plugin -->
    <dependency>
        <groupId>com.jgeppert.struts2.jquery</groupId>
        <artifactId>struts2-jquery-grid-plugin</artifactId>
        <version>3.5.1</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/com.jgeppert.struts2.jquery/struts2-jquery-plugin -->
    <dependency>
        <groupId>com.jgeppert.struts2.jquery</groupId>
        <artifactId>struts2-jquery-plugin</artifactId>
        <version>3.5.1</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/com.jgeppert.struts2.jquery/struts2-jquery-richtext-plugin -->
    <dependency>
        <groupId>com.jgeppert.struts2.jquery</groupId>
        <artifactId>struts2-jquery-richtext-plugin</artifactId>
        <version>3.3.3</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/com.jgeppert.struts2.jquery/struts2-jquery-tree-plugin -->
    <dependency>
        <groupId>com.jgeppert.struts2.jquery</groupId>
        <artifactId>struts2-jquery-tree-plugin</artifactId>
        <version>3.3.3</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/org.apache.struts/struts2-json-plugin -->
    <dependency>
        <groupId>org.apache.struts</groupId>
        <artifactId>struts2-json-plugin</artifactId>
        <version>2.3.4.1</version>
    </dependency>   

    <!-- https://mvnrepository.com/artifact/xml-apis/xml-apis -->
    <dependency>
        <groupId>xml-apis</groupId>
        <artifactId>xml-apis</artifactId>
        <version>1.0.b2</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/org.apache.xmlbeans/xmlbeans -->
    <dependency>
        <groupId>org.apache.xmlbeans</groupId>
        <artifactId>xmlbeans</artifactId>
        <version>2.3.0</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/org.apache.struts.xwork/xwork-core -->
    <dependency>
        <groupId>org.apache.struts.xwork</groupId>
        <artifactId>xwork-core</artifactId>
        <version>2.3.3</version>
    </dependency>    
</dependencies>
<build>
    <finalName>DF_CMS_DEBIT_REPORT</finalName>
    <sourceDirectory>src/com/epic</sourceDirectory>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
                <!--compilerArguments>
                    <endorseddirs>${endorsed.dir}</endorseddirs>
                </compilerArguments-->
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.3</version>
            <configuration>
                <webXml>D:\Projects\DEBIT_REPORTS - 10-04-2019\DF_CMS_DEBIT_REPORT\webapp\WEB-INF\web.xml</webXml>
                <warSourceDirectory>D:\Projects\DEBIT_REPORTS - 10-04-2019\DF_CMS_DEBIT_REPORT\webapp</warSourceDirectory>
                <failOnMissingWebXml>true</failOnMissingWebXml>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <version>2.6</version>
            <executions>
                <execution>
                    <phase>validate</phase>
                    <goals>
                        <goal>copy</goal>
                    </goals>
                    <configuration>
                        <outputDirectory>${endorsed.dir}</outputDirectory>
                        <silent>true</silent>
                        <artifactItems>
                            <artifactItem>
                                <groupId>javax</groupId>
                                <artifactId>javaee-endorsed-api</artifactId>
                                <version>7.0</version>
                                <type>jar</type>
                            </artifactItem>
                        </artifactItems>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

<distributionManagement>
    <repository>
        <id>central</id>
        <name>plugins-releases</name>
        <url>http://localhost:8080/artifactory/plugins-release-local</url>
    </repository>
    <snapshotRepository>
        <id>snapshots</id>
        <name>plugins-snapshot</name>
        <url>http://localhost:8080/artifactory/plugins-snapshot-local</url>
    </snapshotRepository>
</distributionManagement>
</project>```

1 个答案:

答案 0 :(得分:0)

通过在src文件夹中分别创建资源文件夹来添加这些sturts.xml和相关xml文件来解决问题