1、Create New Project
2、Maven -> Jdk -> Next
3、Finish
4、Enable Auto Import
5、配置一下Maven
File -> Settings -> Maven
6、settings.xml
<localRepository>C:\alexsoftware\maven\m2\repository</localRepository>
<mirror>
<id>alimaven</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/repositories/central/</url>
<mirrorOf>central</mirrorOf>
</mirror>
<mirror>
<id>nexus-aliyun</id>
<name>Nexus aliyun</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>
<mirror>
<id>alimaven-new</id>
<mirrorOf>central</mirrorOf>
<name>aliyun maven</name>
<url>https://maven.aliyun.com/repository/central/</url>
</mirror>
<mirror>
<id>aliyun-repos</id>
<name>aliyun-repos</name>
<url>https://maven.aliyun.com/repository/public</url>
<mirrorOf>central</mirrorOf>
</mirror>
<mirror>
<id>sonatype-repos-s</id>
<name>sonatype-repos-s</name>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
<mirrorOf>central</mirrorOf>
</mirror>
<mirror>
<id>repo2</id>
<name>Mirror from Maven Repo2</name>
<url>http://repo2.maven.org/maven2/</url>
<mirrorOf>central</mirrorOf>
</mirror>
<mirror>
<id>centor</id>
<name>Mirror from Maven central</name>
<url>http://central.maven.org/maven2/</url>
<mirrorOf>central</mirrorOf>
</mirror>
<profile>
<id>jdk-1.8</id>
<activation>
<activeByDefault>true</activeByDefault>
<jdk>1.8</jdk>
</activation>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
</properties>
</profile>
7、Project Structure -> Web
8、OK
9、修改web.xml
10、创建并编辑index.jsp
11、pom.xml 添加tomcat插件
<build>
<finalName>webdemo</finalName>
<plugins>
<!-- Run As → Maven Build → tomcat7:run -Dmaven.tomcat.port=8080 -->
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<!-- 指定端口 -->
<port>8080</port>
<!-- 请求路径 -->
<path>/webdemo</path>
<ignorePackaging>true</ignorePackaging>
</configuration>
</plugin>
</plugins>
</build>
12、Tomcat7 Run(启动方式一)
13、启动方式二
1)ok
Add Configuration -> Maven -> Command line -> tomcat7:run -Dmaven.tomcat.port=8080
网友评论