Maven项目的pom.xml常见配置(Eclipse)

来源:互联网 发布:淘宝助理百世快递模板 编辑:程序博客网 时间:2024/06/13 21:49

1.配置缺少的jar包,可在maven repository中查找

<dependencies><dependency>        <groupId>org.apache.tomcat</groupId>        <artifactId>tomcat-servlet-api</artifactId>        <version>7.0.0</version>    </dependency></dependencies>

2.tomcat插件的配置

<build>    <plugins>        <plugin>            <groupId>org.apache.tomcat.maven</groupId>            <artifactId>tomcat7-maven-plugin</artifactId>            <configuration>                <path>/</path>                <port>8080</port>            </configuration>        </plugin>    </plugins></build>

注:使用tomcat插件,需要把2.1中引用的tomcat-servlet-api去掉,否则会产生jar包依赖冲突,会报错。
运行工程,在工程上右键->Run As->Maven build:
执行 clean tomcat7:run

3.排除冲突的jar包

<dependency>    <groupId>junit</groupId>    <artifactId>junit</artifactId>    <!-- 排除冲突jar包 -->    <exclusions>        <exclusion>            <groupId>org.hamcrest</groupId>            <artifactId>hamcrest-core</artifactId>        </exclusion>    </exclusions></dependency>
原创粉丝点击