Code Monkey home page Code Monkey logo

maven-archetype-practice's Introduction

骨架项目生成和使用步骤:
1.对项目demo执行mvn archetype:create-from-project,生成该项目的骨架项目archetype(在target/generated-sources/目录下)
2.对骨架项目archetype进行打包:mvn clean install,打包到本地仓库
3.用idea新建项目,选择新生成的archetype,仓库设为本地仓库,继续设置新项目的maven坐标,完成相关操作
4.执行完以上步骤,耐心等待即可生成和demo一样组织结构的maven普通项目

ps新创建的maven普通项目src/main/resources目录下遗留了骨架项目中的两个配置文件,后续研究如何避免生成这俩文件:
demo-resources/pom.xml
META-INF/maven/demo-metadata.xml


2017-09-08更新:
1.解决生成多余文件的问题
对项目demo执行mvn archetype:create-from-project,生成该项目的骨架项目archetype后,需要修改一下archetype的配置:
将src/main/resources/META-INF/maven/archetype-metadata.xml修改如下,指定要包含的文件路径

<fileSet filtered="true" encoding="UTF-8">
      <directory>src/main/resources</directory>
      <includes>
        <!--此处改写,避免生成不必要的文件-->
        <include>mybatis/**/*.*</include>
        <include>spring/**/*.*</include>
        <include>*.*</include>
        <!--<include>**/*.txt</include>
        <include>**/*.xml</include>
        <include>**/*.properties</include>-->
      </includes>
</fileSet>
PS:修改原生项目、骨架项目后,不会生成多余文件,不再需要修改archetype的配置
2.使用骨架项目创建的项目,.java文件出现红色图标J,这是由于项目未把该文件路径指定为源码路径,在project Structure的Modules中将该文件路径指定为源码路径即可,下面是idea的官方资料https://www.jetbrains.com/help/idea/configuring-content-roots.html

maven-archetype-practice's People

Contributors

duomu avatar

Watchers

James Cloos avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.