maven 插件使用(maven学习二)

版权声明:随意转载。 https://blog.csdn.net/dengjili/article/details/85270793

mavn插件地址

https://maven.apache.org/plugins/
http://www.mojohaus.org/plugins.html

tomcat

官网教程:https://tomcat.apache.org/maven-plugin-2.2/run-mojo-features.html

use: mvn tomcat7:run

  <plugin>
    <groupId>org.apache.tomcat.maven</groupId>
    <artifactId>tomcat7-maven-plugin</artifactId>
    <!-- or if you want to use tomcat 6.x
    <artifactId>tomcat6-maven-plugin</artifactId>
    -->
    <version>2.2</version>
    <configuration>
      <!-- http port -->
      <port>9090</port>
      <!-- application path always starts with /-->
      <path>/</path>
      <!-- optional path to a context file -->
      <contextFile>${tomcatContextXml}</contextFile>
      <!-- optional system propoerties you want to add -->
      <systemProperties>
        <appserver.base>${project.build.directory}/appserver-base</appserver.base>
        <appserver.home>${project.build.directory}/appserver-home</appserver.home>
        <derby.system.home>${project.build.directory}/appserver-base/logs</derby.system.home>
        <java.io.tmpdir>${project.build.directory}</java.io.tmpdir>
      </systemProperties>
      <!-- if you want to use test dependencies rather than only runtime -->
      <useTestClasspath>false</useTestClasspath>
      <!-- optional if you want to add some extra directories into the classloader -->
      <additionalClasspathDirs>
        <additionalClasspathDir></additionalClasspathDir>
      </additionalClasspathDirs>
    </configuration>
    <!-- For any extra dependencies needed when running embedded Tomcat (not WAR dependencies) add them below -->
    <dependencies>
      <dependency>
        <groupId>org.apache.derby</groupId>
        <artifactId>derby</artifactId>
        <version>\${derbyVersion}</version>
      </dependency>
      <dependency>
        <groupId>javax.mail</groupId>
        <artifactId>mail</artifactId>
        <version>1.4</version>
      </dependency>
    </dependencies>
  </plugin>

实际工程运行配置

<build>
		<plugins>
			<plugin>
				<groupId>org.apache.tomcat.maven</groupId>
				<artifactId>tomcat7-maven-plugin</artifactId>
				<version>2.2</version>
				<configuration>
					<port>9090</port>
     				<path>/web</path>
				</configuration>
			</plugin>
		</plugins>
	</build>

运行
mvn tomcat7:run

在这里插入图片描述

测试
在这里插入图片描述

常用的命令:

tomcat:deploy   --部署一个web war包
tomcat:reload   --重新加载web war包
tomcat:start    --启动tomcat
tomcat:stop    --停止tomcat
tomcat:undeploy--停止一个war包
tomcat:run  启动嵌入式tomcat ,并运行当前项目

统一版本号

			<plugin>
				<groupId>org.codehaus.mojo</groupId>
				<artifactId>versions-maven-plugin</artifactId>
				<version>2.7</version>
			</plugin>

统一设置命令

mvn versions:set -DnewVersion=0.0.1-SNAPSHOT

提示命令

versions:help

source命令

		<plugin>
				<groupId>org.apache.maven.plugins</groupId>
       			<artifactId>maven-source-plugin</artifactId>
				<version>3.0.1</version>
				<configuration>
					<attach>true</attach>
				</configuration>
				<executions>
					<execution>
						<phase>package</phase>
						<goals>
							<goal>jar-no-fork</goal>
						</goals>
					</execution>
				</executions>
			</plugin>

package阶段执行goals命令jar-no-fork

assembly插件实现自定义打包

https://www.cnblogs.com/hafiz/p/6538332.html

猜你喜欢

转载自blog.csdn.net/dengjili/article/details/85270793
今日推荐