Skip to content

Instantly share code, notes, and snippets.

@is00hcw
Last active January 4, 2016 22:19
Show Gist options
  • Save is00hcw/8687281 to your computer and use it in GitHub Desktop.
Save is00hcw/8687281 to your computer and use it in GitHub Desktop.
http://www.mkyong.com/maven/how-to-create-a-web-application-project-with-maven/
mvn archetype:generate -DgroupId=com.mkyong -DartifactId=CounterWebApp -DarchetypeArtifactId=maven-archetype-webapp -DinteractiveMode=false
mvn eclipse:eclipse -Dwtpversion=2.0
<repositories>
<repository>
<id>central</id>
<name>Central Repository</name>
<url>http://repo.maven.apache.org/maven2</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>offical</id>
<name>Maven Official Repository</name>
<url>http://repo1.maven.org/maven2</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>sun</id>
<name>Sun Repository</name>
<url>http://download.java.net/maven/2/</url>
</repository>
<repository>
<id>sonatype</id>
<name>Sonatype Repository</name>
<url>http://repository.sonatype.org/content/groups/public/</url>
</repository>
<repository>
<id>repo.springsource.org-release</id>
<name>springsource repository</name>
<url>http://repo.springsource.org/release</url>
</repository>
<repository>
<id>repository.jboss.org-public</id>
<name>JBoss repository</name>
<url>https://repository.jboss.org/nexus/content/groups/public</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>offical</id>
<name>Maven Official Repository</name>
<url>http://repo1.maven.org/maven2</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>jboss-public-repository-group</id>
<url>https://repository.jboss.org/nexus/content/groups/public-jboss
</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>sun</id>
<name>Sun Repository</name>
<url>http://download.java.net/maven/2/</url>
</pluginRepository>
<pluginRepository>
<id>sonatype</id>
<name>Sonatype Repository</name>
<url>http://repository.sonatype.org/content/groups/public/</url>
</pluginRepository>
<pluginRepository>
<id>Codehaus repository</id>
<url>http://repository.codehaus.org/</url>
</pluginRepository>
</pluginRepositories>
<!-- log4j -->
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.12</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.2</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.2</version>
</dependency>
<!-- mybatis -->
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>3.1.1</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
<version>1.1.1</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<reporting>
<plugins>
<!-- pmd and other reporting plugins -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jxr-plugin</artifactId>
<version>2.2</version>
</plugin>
</plugins>
</reporting>
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
<configuration>
<source>${jdk.version}</source>
<target>${jdk.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>${jetty.version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<warName>${project.artifactId}</warName>
<webResources>
<resource>
<directory>lib/</directory>
<targetPath>WEB-INF/lib</targetPath>
<includes>
<include>**/*.jar</include>
</includes>
</resource>
</webResources>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId> <!-- http://www.cnblogs.com/huang0925/p/3148389.html -->
<version>2.11</version>
<configuration>
<configLocation>config/sun_checks.xml</configLocation>
<!--<configLocation>config/maven_checks.xml</configLocation>-->
<!--<configLocation>config/turbine_checks.xml</configLocation>-->
<!--<configLocation>config/avalon_checks.xml</configLocation>-->
<includeResources>false</includeResources>
<failOnViolation>true</failOnViolation>
<violationSeverity>info</violationSeverity>
<maxAllowedViolations>0</maxAllowedViolations>
<consoleOutput>true</consoleOutput>
<encoding>UTF-8</encoding>
<includes>
**\/com\/**.java,**\/otherpackage\/**.java
</includes>
</configuration>
<executions>
<execution>
<goals>
<goal>check</goal>
</goals>
<phase>validate</phase>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>2.7.1</version>
<configuration>
<failurePriority>5</failurePriority>
<failOnViolation>true</failOnViolation>
<targetJdk>${jdk.version}</targetJdk>
<verbose>true</verbose>
<outputEncoding>UTF-8</outputEncoding>
<aggregate>true</aggregate>
<rulesets>
<ruleset>rulesets/basic.xml</ruleset>
<ruleset>rulesets/unusedcode.xml</ruleset>
<ruleset>rulesets/braces.xml</ruleset>
<ruleset>rulesets/naming.xml</ruleset>
<ruleset>rulesets/strings.xml</ruleset>
</rulesets>
<includes>
<include>**\/com\/**.java</include>
<include>**\/otherpackage\/**.java</include>
</includes>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>2.5.2</version>
<configuration>
<onlyAnalyze>
com.*,
</onlyAnalyze>
<!--<includeFilterFile>findbugs.xml</includeFilterFile>-->
<failOnError>true</failOnError>
<outputEncoding>UTF-8</outputEncoding>
<threshold>Low</threshold>
<xmlOutput>true</xmlOutput>
<effort>Max</effort>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId> <!-- http://mojo.codehaus.org/cobertura-maven-plugin/usage.html -->
<version>2.5.1</version>
<configuration>
<check>true</check>
<formats>
<format>html</format>
<format>xml</format>
</formats>
<instrumentation>
<ignores>
</ignores>
<excludes>
<exclude>**/*Test.class</exclude>
<exclude>**/Test*.class</exclude>
</excludes>
</instrumentation>
</configuration>
<executions>
<execution>
<goals>
<goal>cobertura</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment