首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Maven原型生成不包括来自原型-资源的文件。

Maven原型生成不包括来自原型-资源的文件。
EN

Stack Overflow用户
提问于 2020-01-28 20:45:50
回答 1查看 1.6K关注 0票数 3

我正在创建一个maven原型,但是当我用这种原型生成一个项目时,源是空的。

有什么东西不见了吗?

一开始有什么简单的原型吗?我尝试了maven原型,但是每个项目都继承了父artifactId maven原型包。

Maven原型

代码语言:javascript
复制
base-archetype
  -src
    -main
      -java
      -resources
        -archetype-resources
          -resources
            -META-INF
              messages.properties
          -webapp
            -WEB-INF
              beans.xml
          pom.xml(b)
        -META-INF
          -maven
            archetype-metadata.xml
    -test
  -target
  pom.xml(a)

pom.xml(a)

代码语言:javascript
复制
<?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.javalabs</groupId>
    <artifactId>simple-archetype</artifactId>
    <version>0.0.1</version>
    <packaging>maven-archetype</packaging>
...    

    <build>
        <extensions>
            <extension>
                <groupId>org.apache.maven.archetype</groupId>
                <artifactId>archetype-packaging</artifactId>
                <version>3.1.2</version>
            </extension>
        </extensions>

        <pluginManagement>
            <plugins>
                <plugin>
                    <artifactId>maven-archetype-plugin</artifactId>
                    <version>3.0.1</version>
                </plugin>
            </plugins>
        </pluginManagement>

        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <version>3.0.1</version>
                <executions>
                    <execution>
                        <id>attach-sources</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>jar-no-fork</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-gpg-plugin</artifactId>
                <version>1.6</version>
                <executions>
                    <execution>
                        <id>sign-artifacts</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>sign</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            ...
        </plugins>
    </build>
    ...
</project>

archetype-metadata.xml

代码语言:javascript
复制
<archetype-descriptor
        xsi:schemaLocation="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0
        http://maven.apache.org/xsd/archetype-descriptor-1.0.0.xsd"
        xmlns="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        name="jakartaee-essentials-archetype">

    <fileSets>
        <fileSet filtered="true" packaged="true" encoding="UTF-8">
            <directory>src/main/java</directory>
            <includes>
                <include>**/*.java</include>
            </includes>
        </fileSet>

        <fileSet filtered="true" packaged="true" encoding="UTF-8">
            <directory>src/main/resources</directory>
            <includes>
                <include>**/*.xml</include>
                <include>**/*.properties</include>
            </includes>
        </fileSet>

        <fileSet filtered="true" packaged="false" encoding="UTF-8">
            <directory>src/main/webapp</directory>
            <includes>
                <include>**/*.xml</include>
                <include>**/*.properties</include>
            </includes>
        </fileSet>

        <fileSet>
            <directory>src/test/java</directory>
        </fileSet>

        <fileSet filtered="false" packaged="false" encoding="UTF-8">
            <directory></directory>
            <includes>
                <include>.gitignore</include>
            </includes>
        </fileSet>
    </fileSets>

</archetype-descriptor>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-03-22 19:31:14

原型结构上存在一些错误,缺乏原型资源文件夹中的src和主层次。

代码语言:javascript
复制
base-archetype
  -src
    -main
      -java
      -resources
        -archetype-resources
          -**src**
            -**main**
              -resources
                -META-INF
                  messages.properties
                -webapp
                  -WEB-INF
                    beans.xml
            pom.xml(b)
        -META-INF
          -maven
            archetype-metadata.xml
    -test
  -target
  pom.xml(a)
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/59956755

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档