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
36
2
下载
Maven: Apache Maven是一个开源的项目管理和构建工具,主要用于Java项目。适合需要自动化项目构建和依赖管理的开发者。特点包括约定优于配置、易于使用和社区驱动。
最近提交(Master分支:1 个月前 )
001c86bb Bumps [ch.qos.logback:logback-classic](https://github.com/qos-ch/logback) from 1.5.20 to 1.5.21. - [Release notes](https://github.com/qos-ch/logback/releases) - [Commits](https://github.com/qos-ch/logback/compare/v_1.5.20...v_1.5.21) --- updated-dependencies: - dependency-name: ch.qos.logback:logback-classic dependency-version: 1.5.21 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> 1 天前
f2e9432a The exception was observed in the integration tests of Maven Compiler Plugin when Maven is executed with the `-T4` option. 1 天前
Logo

新一代开源开发者平台 GitCode,通过集成代码托管服务、代码仓库以及可信赖的开源组件库,让开发者可以在云端进行代码托管和开发。旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐