exec-maven-plugin、 tomcat7-maven-plugin 、tomcat-maven-plugin、jetty-maven-plugin 几个重要插件的使用教程

用maven管理项目时,有几个常用、重要的插件可以让我们非常方便地运行项目。


exec-maven-plugin:可以让我们方便的运行普通的java应用或者spring应用项目,本人非常喜欢这个插件。

pom.xml文件插件配置:

          <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>1.1</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>java</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <classpathScope>test</classpathScope>
                    <mainClass>com.ycy.upms.rpc.YcyUpmsRpcServiceApplication</mainClass>
                </configuration>
            </plugin>
             

配置注意:红色需要配置public static void main(String[] args)主方法所在的全限定类路径。

maven 命令行:

mvn  exec:java


tomcat7-maven-plugin(tomcat7插件): 运行javaWeb项目。

pom.xml文件插件配置:

                       <plugin>
				<groupId>org.apache.tomcat.maven</groupId>
				<artifactId>tomcat7-maven-plugin</artifactId>
				<version>2.2</version> 
				<configuration>
					<port>8080</port>
					<path>/</path>
					<uriEncoding>utf-8</uriEncoding>
				</configuration>
			</plugin>

maven命令行:

mvn tomcat7:run

tomcat-maven-plugin(tomcat6)插件

pom.xml文件插件配置

                   <plugin>
	                <groupId>org.codehaus.mojo</groupId>
	                <artifactId>tomcat-maven-plugin</artifactId>
	                <version>1.1</version>
	                <configuration>
	                    <path>/</path>
	                    <port>8080</port>
	                    <uriEncoding>utf-8</uriEncoding>
	                    <server>tomcat6</server>
	                </configuration>
	            </plugin>
	       

maven 命令行:

mvn tomcat:run

jetty-maven-plugin(jetty插件):运行javaWeb项目。


pom.xml文件插件配置:

          <plugin>
                <groupId>org.eclipse.jetty</groupId>
                <artifactId>jetty-maven-plugin</artifactId>
                <version>9.2.7.v20150116</version>
                <configuration>
                    <scanIntervalSeconds>3</scanIntervalSeconds>
                    <webApp>
                        <contextPath>/</contextPath>
                    </webApp>
                    <httpConnector>
                        <port>8080</port>
                    </httpConnector>
                    <reload>automatic</reload>
                </configuration>
            </plugin>
            


maven命令行:

mvn jetty:run





猜你喜欢

转载自blog.csdn.net/pingweicheng/article/details/80872571