1 设置maven镜像,提升下载速度
D:\software\apache-maven-3.3.9\conf\settings.xml
<mirrors> <mirror> <id>alimaven</id> <name>aliyun maven</name> <url>http://maven.aliyun.com/nexus/content/groups/public/</url> <mirrorOf>central</mirrorOf> </mirror> </mirrors>
2 设置tomcat服务器(tomcat7:run时 会启动一个tomcat)
D:\software\apache-maven-3.3.9\conf\settings.xml
<servers> <server> <id>Tomcat7</id> <username>tomcat</username> <password>123456</password> </server> </servers>
3 配置Maven插件
/FH_ADMIN/pom.xml
<!-- 编译插件 --> <build> <finalName>FH_ADMIN</finalName> <plugins> <!-- 配置tomcat插件 --> <plugin> <groupId>org.apache.tomcat.maven</groupId> <artifactId>tomcat7-maven-plugin</artifactId> <configuration> <url>http://localhost:8080/manager/text</url> tomcat管理路径 <server>Tomcat7</server> 与settings.xml文件中Server的id相同 <path>/</path> 应用的部署位置 <username>tomcat</username> <password>123456</password> </configuration> </plugin> </plugins> </build>
<!-- 配置maven插件 -->
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>2.1</version> <configuration> <source>1.7</source> <target>1.7</target> <encoding>${project.build.sourceEncoding}</encoding> <compilerArguments> <verbose /> <bootclasspath>${java.home}/lib/rt.jar;${java.home}/lib/jce.jar</bootclasspath> </compilerArguments> </configuration> </plugin>
4 解决tomcat插件时的Jar包冲突
<dependency> <groupId>javax.servlet</groupId> <artifactId>servlet-api</artifactId> <version>2.5</version> <!-- 关键代码 --> <scope>provided</scope> </dependency>
时间: 2024-12-27 22:55:03