美文网首页
Maven 自动配置与插件

Maven 自动配置与插件

作者: Tinyspot | 来源:发表于2022-08-25 07:57 被阅读0次

auto-config.xml

<config>
  <group>
    <property name="local.host" defaultValue="127.0.0.1" description="datasource master host" />
  </group>
  <script>
    <generate template="application.properties.vm" destfile="application.properties" />
  </script>
</config>

编写 pom.xml 文件引入 autoconfig 插件
<plugin>
    <groupId>com.alibaba.citrus.tool</groupId>
    <artifactId>autoconfig-maven-plugin</artifactId>
    <version>1.2</version>
</plugin>

编译打包:
(1)您需要现在更新此文件吗?[Yes][No] : yes
(2)请选择 [1-3][Quit][Next]: 输入 quit 按回车
(3)即将保存到文件 "file:/......" 中,确定?[Yes][No] : 输入 yes 按回车

Maven插件

Maven的生命周期是抽象的,其实际行为都由插件来完成

// 在父工程添加编译插件
<build>
    <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>
                <encoding>UTF-8</encoding>
            </configuration>
        </plugin>
    </plugins>
</build>

插件目标(Plugin Goal)

  • dependency:tree
  • -D参数,并伴随一个参数键=参数值的形式,来配置插件目标的参数
  • 目标前缀(Goal Prefix)

Maven Archetype Plugin

  • Maven 3 mvn archetype:generate
  • maven-archetype-quickstart
  • mvn archetype:generate
  • 自定义一个 Archetype
  • While prototype and archetype are often used interchangeably, they really mean quite different things. An archetype is a perfect and unchanging form that existing things or people can approach but never duplicate (: the archetype of a mother), while a prototype is an early, usually unrefined version of something that later versions reflect but may depart from (: a prototype for a hydrogen-fueled car).

command

mvn spring-boot:run
mvn [plugin-name]:[goal-name]
mvn tomcat7:run  # eg. 在tomcat容器中运行web应用

* -D `mvn package -Dmaven.test.skip=true` 
* -p 指定 profile 配置

版本管理(Version Management)和版本控制(Version Control)

  • 版本管理是指项目整体版本的演变过程管理,如从1.0-SNAPSHOT到1.0,再到1.1-SNAPSHOT。版本控制是指借助版本控制工具(如Subversion)追踪代码的每一个变更
  • 主干(trunk)、标签(tag)和branch(分支)

参考

相关文章

网友评论

      本文标题:Maven 自动配置与插件

      本文链接:https://www.haomeiwen.com/subject/fuwpbrtx.html