JAVA开发环境Maven

"Maven简洁开发"

Posted by Waterfox on December 14, 2016

“懒人java开发环境必备+常用的maven配置,分享 ”

国内源

        <!--开源中国 时好时坏
		<mirror>
	      <id>CN</id>
	      <name>OSChina Central</name>
	      <mirrorOf>*</mirrorOf>
	      <url>http://maven.oschina.net/content/groups/public/</url>
	    </mirror>
		-->

		<!--405ms
		<mirror>
	      <id>CN</id>
	      <name>OSChina Central</name>
	      <mirrorOf>*</mirrorOf>
	      <url>https://repository.sonatype.org/content/groups/public/</url>
	    </mirror>
		-->

		<!--236ms
		<mirror>
	      <id>CN</id>
	      <name>OSChina Central</name>
	      <mirrorOf>*</mirrorOf>
	      <url>http://repository.jboss.com/maven2/</url>
	    </mirror>
		-->

		<mirror>
	      <id>aliyun</id>
	      <name>aliyunCentral</name>
	      <mirrorOf>*</mirrorOf>
	      <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
	    </mirror>

web插件推荐

<build>
		<plugins>
		<!--编译插件1.6是为了兼容maven能支持的jdk-->
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-compiler-plugin</artifactId>
				<version>2.3.2</version>
				<configuration>
					<source>1.6</source>
					<target>1.6</target>
					<compilerArguments>
						<endorseddirs>${endorsed.dir}</endorseddirs>
					</compilerArguments>
				</configuration>
			</plugin>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-war-plugin</artifactId>
				<version>2.1.1</version>
				<configuration>
					<failOnMissingWebXml>false</failOnMissingWebXml>
				</configuration>
			</plugin>
			
			<!--jetty:run -Djetty.port=8080-->
			<!--jetty的web容器-->
			<plugin>
				<groupId>org.mortbay.jetty</groupId>
				<artifactId>maven-jetty-plugin</artifactId>
				<version>6.1.26</version>
				<configuration>
				    <!--这里可以指定特定的web.xml目录-->
					<webDefaultXml>src/main/resources/webdefault.xml</webDefaultXml>
				</configuration>
			<!--指定根目录,如果不设置,默认是首先以项目名作为根目录-->
			<contextPath>/</contextPath>
			</plugin>
			
			
			<!-- clean tomcat7:run 注意: -->
			<!-- 配置tomcat插件 -->
			<plugin>
				<groupId>org.apache.tomcat.maven</groupId>
				<artifactId>tomcat7-maven-plugin</artifactId>
				<configuration>
					<port>80</port>
					<path>/</path>
				</configuration>
			</plugin>
	
			
			<!--css压缩-->
			<plugin>
				<groupId>net.alchim31.maven</groupId>
				<artifactId>yuicompressor-maven-plugin</artifactId>
				<version>1.1</version>
			</plugin>
			<!--不执行Test步骤,这个名称是历史原因,不叫maventestplugin-->
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-surefire-plugin</artifactId>
				<configuration>
					<skip>true</skip>
				</configuration>
			</plugin>
			
    </plugins>
</build>