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>
GitHub 加速计划 / ma / maven
4.28 K
2.65 K
下载
Maven: Apache Maven是一个开源的项目管理和构建工具,主要用于Java项目。适合需要自动化项目构建和依赖管理的开发者。特点包括约定优于配置、易于使用和社区驱动。
最近提交(Master分支:8 天前 )
7ea795b7 The `FilteredProjectDependencyGraph` class fix for non-transitive case and an UT. Also contains some improvement in classes, making them immutable as intended. --- https://issues.apache.org/jira/browse/MNG-8256 6 天前
2b13a43c 7 天前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐