简体   繁体   English

找不到Maven“资源”文件夹

[英]Maven 'resources' folder not found

On the first step, I have a dynamic web project in Eclipse with folder resources in WebContent第一步,我在 Eclipse 中有一个动态 Web 项目,在WebContent有文件夹resources

Now I like to try Maven, I use the 'convert dynamic web project to maven' with right click on the project and configure => convert to maven现在我喜欢尝试 Maven,我使用'convert dynamic web project to maven',右键单击项目并配置=>转换为 maven

I set the pom.xml with dependence for the jar and it's ok.我将pom.xml设置为对 jar 的依赖,这没问题。

I run the application but I don't see the resources folder of project in my WebContent with all css, js, ....我运行该应用程序,但在我的 WebContent 中没有看到项目的资源文件夹,其中包含所有 css、js、....

I changed the default folder src / app / resources for maven (i think) by WebContent / resources , but it's not working我通过WebContent / resources更改了 maven(我认为)的默认文件夹src / app / resources WebContent / resources ,但它不起作用

Do you have an idea for me?你对我有什么想法吗?

my pom.xml我的 pom.xml

<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>Immo2_0</groupId>
<artifactId>Immo2_0</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>Immo2_0</name>
<build>
    <sourceDirectory>src</sourceDirectory>
    <resources>
        <resource>
            <directory>src</directory>
            <excludes>
                <exclude>**/*.java</exclude>
            </excludes>
        </resource>
    </resources>
    <plugins>
        <plugin>
            <artifactId>maven-war-plugin</artifactId>
            <version>3.0.0</version>
            <configuration>
                <warSourceDirectory>WebContent</warSourceDirectory>
            </configuration>
        </plugin>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.7.0</version>
            <configuration>
                <source>10</source>
                <target>10</target>
            </configuration>
        </plugin>           
    </plugins>
</build>
<dependencies>
    <!-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 -->
    <dependency>
        <groupId>org.apache.commons</groupId>
        <artifactId>commons-lang3</artifactId>
        <version>3.7</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/c3p0/c3p0 -->
    <dependency>
        <groupId>c3p0</groupId>
        <artifactId>c3p0</artifactId>
        <version>0.9.1.2</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/com.sun.codemodel/codemodel -->
    <dependency>
        <groupId>com.sun.codemodel</groupId>
        <artifactId>codemodel</artifactId>
        <version>2.6</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/commons-beanutils/commons-beanutils -->
    <dependency>
        <groupId>commons-beanutils</groupId>
        <artifactId>commons-beanutils</artifactId>
        <version>1.9.3</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/commons-digester/commons-digester -->
    <dependency>
        <groupId>commons-digester</groupId>
        <artifactId>commons-digester</artifactId>
        <version>2.1</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/commons-fileupload/commons-fileupload -->
    <dependency>
        <groupId>commons-fileupload</groupId>
        <artifactId>commons-fileupload</artifactId>
        <version>1.3.3</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/commons-io/commons-io -->
    <dependency>
        <groupId>commons-io</groupId>
        <artifactId>commons-io</artifactId>
        <version>2.6</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/commons-logging/commons-logging -->
    <dependency>
        <groupId>commons-logging</groupId>
        <artifactId>commons-logging</artifactId>
        <version>1.2</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
    <dependency>
        <groupId>com.google.code.gson</groupId>
        <artifactId>gson</artifactId>
        <version>2.8.5</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/javax.activation/javax.activation-api -->
    <dependency>
        <groupId>javax.activation</groupId>
        <artifactId>javax.activation-api</artifactId>
        <version>1.2.0</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/javax.el/javax.el-api -->
    <dependency>
        <groupId>javax.el</groupId>
        <artifactId>javax.el-api</artifactId>
        <version>3.0.1-b06</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.glassfish/javax.faces -->
    <dependency>
        <groupId>org.glassfish</groupId>
        <artifactId>javax.faces</artifactId>
        <version>2.4.0</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/javax.mail/javax.mail-api -->
    <dependency>
        <groupId>javax.mail</groupId>
        <artifactId>javax.mail-api</artifactId>
        <version>1.6.1</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/javax.mail/mail -->
    <dependency>
        <groupId>javax.mail</groupId>
        <artifactId>mail</artifactId>
        <version>1.5.0-b01</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.jdom/jdom2 -->
    <dependency>
        <groupId>org.jdom</groupId>
        <artifactId>jdom2</artifactId>
        <version>2.0.6</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.eclipse.jdt/core -->
    <dependency>
        <groupId>org.eclipse.jdt</groupId>
        <artifactId>core</artifactId>
        <version>3.3.0-v_771</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.jsonschema2pojo/jsonschema2pojo-core -->
    <dependency>
        <groupId>org.jsonschema2pojo</groupId>
        <artifactId>jsonschema2pojo-core</artifactId>
        <version>1.0.0-alpha4</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/javax.servlet/jstl -->
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>jstl</artifactId>
        <version>1.2</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/log4j/log4j -->
    <dependency>
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
        <version>1.2.17</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.apache.poi/poi -->
    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi</artifactId>
        <version>3.17</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.primefaces/primefaces -->
    <dependency>
        <groupId>org.primefaces</groupId>
        <artifactId>primefaces</artifactId>
        <version>6.2</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.primefaces.extensions/primefaces-extensions -->
    <dependency>
        <groupId>org.primefaces.extensions</groupId>
        <artifactId>primefaces-extensions</artifactId>
        <version>6.2.8</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.quartz-scheduler/quartz -->
    <dependency>
        <groupId>org.quartz-scheduler</groupId>
        <artifactId>quartz</artifactId>
        <version>2.3.0</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.quartz-scheduler/quartz-jobs -->
    <dependency>
        <groupId>org.quartz-scheduler</groupId>
        <artifactId>quartz-jobs</artifactId>
        <version>2.3.0</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/net.java.dev.rome/rome -->
    <dependency>
        <groupId>net.java.dev.rome</groupId>
        <artifactId>rome</artifactId>
        <version>1.0.0</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api -->
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>javax.servlet-api</artifactId>
        <version>4.0.1</version>
        <scope>provided</scope>
    </dependency>

    <!-- https://mvnrepository.com/artifact/javax.enterprise/cdi-api -->
    <dependency>
        <groupId>javax.enterprise</groupId>
        <artifactId>cdi-api</artifactId>
        <version>2.0.SP1</version>
        <scope>provided</scope>
    </dependency>
    <!-- https://mvnrepository.com/artifact/javax.annotation/javax.annotation-api -->
    <dependency>
        <groupId>javax.annotation</groupId>
        <artifactId>javax.annotation-api</artifactId>
        <version>1.3.2</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.jboss.weld.servlet/weld-servlet -->
    <dependency>
        <groupId>org.jboss.weld.servlet</groupId>
        <artifactId>weld-servlet</artifactId>
        <version>2.4.7.Final</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/com.sun.facelets/jsf-facelets -->
    <dependency>
        <groupId>com.sun.facelets</groupId>
        <artifactId>jsf-facelets</artifactId>
        <version>1.1.14</version>
    </dependency>
</dependencies>

My folder :我的文件夹: 在此处输入图片说明

The default structure (which I strongly reccomend you use) for Maven is: Maven 的默认结构(我强烈建议您使用)是:

src/
src/main
src/main/webapp
src/main/webapp/index.jsp
src/main/webapp/WEB-INF
src/main/webapp/WEB-INF/web.xml
src/main/resources
src/main/resources/test.properties

The maven war plugin will take care of the rest, and produce a war that looks like: Maven 战争插件会处理剩下的事情,并产生一个如下所示的战争:

     0 Wed Aug 15 12:47:12 BST 2018 META-INF/
   130 Wed Aug 15 12:47:10 BST 2018 META-INF/MANIFEST.MF
     0 Wed Aug 15 12:47:12 BST 2018 WEB-INF/
     0 Wed Aug 15 12:47:12 BST 2018 WEB-INF/classes/
    52 Wed Aug 15 12:46:22 BST 2018 index.jsp
     0 Wed Aug 15 12:47:12 BST 2018 WEB-INF/classes/test.properties
   215 Wed Aug 15 12:46:22 BST 2018 WEB-INF/web.xml
     0 Wed Aug 15 12:47:12 BST 2018 META-INF/maven/
     0 Wed Aug 15 12:47:12 BST 2018 META-INF/maven/com.greg/
     0 Wed Aug 15 12:47:12 BST 2018 META-INF/maven/com.greg/war-example/
   716 Wed Aug 15 12:46:22 BST 2018 META-INF/maven/com.greg/war-example/pom.xml
   111 Wed Aug 15 12:47:12 BST 2018 META-INF/maven/com.greg/war-example/pom.properties

You can create example projects from archetypes, I created the one above with:您可以从原型创建示例项目,我在上面创建了一个:

mvn archetype:generate -DarchetypeArtifactId=maven-archetype-webapp

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM