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

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了不在war文件的类文件中创建struts.xml文件相关的知识,希望对你有一定的参考价值。

我将我的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:ProjectsDEBIT_REPORTS - 10-04-2019DF_CMS_DEBIT_REPORTwebappWEB-INFweb.xml</webXml>
                <warSourceDirectory>D:ProjectsDEBIT_REPORTS - 10-04-2019DF_CMS_DEBIT_REPORTwebapp</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>```
答案

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

以上是关于不在war文件的类文件中创建struts.xml文件的主要内容,如果未能解决你的问题,请参考以下文章

struts.xml文件:

如何在 NetBeans 中创建我的项目的 war 文件?

Struts2环境搭建

mkfifo() 不在 C 中创建文件

使 SaveFileDialog 不在用户选择的目录中创建测试文件

Android不在图库中创建文件夹