2017-01-19 3 views
0

У меня есть простое приложение Maven, которое я строю с Maven (просто чистая установка).Maven не включая папку ресурсов в webapp archetype

Приложение было создано, начиная с архетипа maven webapp.

При создании и создании войны я хочу, чтобы src/main/resources и все его содержимое были включены в .war, однако этого не происходит.

Я использую следующие построить в моей pom.xml

<build> 
     <resources> 
      <resource> 
       <directory>src/main/resources</directory> 
      </resource> 
     </resources> 
     <plugins> 
      <plugin> 
       <groupId>org.glassfish.maven.plugin</groupId> 
       <artifactId>maven-glassfish-plugin</artifactId> 
      </plugin> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-compiler-plugin</artifactId> 
       <configuration> 
        <source>1.8</source> 
        <target>1.8</target> 
       </configuration> 
      </plugin> 
     </plugins> 
    </build> 

ответ

1

Я использовал Maven-архетип-веб-приложение, ПОМ является:

<?xml version="1.0"?> 
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 
    <modelVersion>4.0.0</modelVersion> 
    <parent> 
    <groupId>com.greg</groupId> 
    <artifactId>ear-example</artifactId> 
    <version>1.0-SNAPSHOT</version> 
    </parent> 
    <groupId>com.greg</groupId> 
    <artifactId>example-war</artifactId> 
    <version>1.0-SNAPSHOT</version> 
    <packaging>war</packaging> 
    <name>example-war Maven Webapp</name> 
    <url>http://maven.apache.org</url> 
    <dependencies> 
    <dependency> 
     <groupId>junit</groupId> 
     <artifactId>junit</artifactId> 
     <version>3.8.1</version> 
     <scope>test</scope> 
    </dependency> 
    </dependencies> 
    <build> 
    <finalName>example-war</finalName> 
    </build> 
</project> 

Я добавил изображение и файл свойств

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

jar tvf target/example-war.war 
    0 Thu Jan 19 15:28:18 GMT 2017 META-INF/ 
    134 Thu Jan 19 15:28:16 GMT 2017 META-INF/MANIFEST.MF 
    0 Thu Jan 19 15:28:18 GMT 2017 WEB-INF/ 
    0 Thu Jan 19 15:28:18 GMT 2017 WEB-INF/classes/ 
    57 Thu Jan 19 15:24:40 GMT 2017 index.jsp 
    0 Thu Jan 19 15:28:16 GMT 2017 WEB-INF/classes/test.img 
    0 Thu Jan 19 15:28:16 GMT 2017 WEB-INF/classes/test.properties 
    222 Thu Jan 19 15:24:40 GMT 2017 WEB-INF/web.xml 
    0 Thu Jan 19 15:28:18 GMT 2017 META-INF/maven/ 
    0 Thu Jan 19 15:28:18 GMT 2017 META-INF/maven/com.greg/ 
    0 Thu Jan 19 15:28:18 GMT 2017 META-INF/maven/com.greg/example-war/ 
    875 Thu Jan 19 15:26:00 GMT 2017 META-INF/maven/com.greg/example-war/pom.xml 
    116 Thu Jan 19 15:28:18 GMT 2017 META-INF/maven/com.greg/example-war/pom.properties 
Смежные вопросы