idea建web项目怎样将jar包放入WEB-INF下的lib目录中

idea建web项目怎样将jar包放入WEB-INF下的lib目录中

问题描述:

我在使用IDEA建web项目时,必须要把一些用到的JAR包导入到tomcat安装目录下才能正常运行,如何才能将JAR包导入到WEB-INF下的lib中,而不需要将JAR包导入tomcat的安装目录中.我每次导入JAR包,都不会再WEB-INF的lib中显示.

那是因为 IDEA 的 maven 项目是通过 pom.xml 文件来添加依赖的,然后项目打包是自动将 pom.xml 中的依赖拷贝到应用的 lib 目录中。
如果不在 pom.xml 配置仓库 jar 包依赖的话,则需要收到将 lib 中的 jar 包在 pom.xml 中配置,方法为:

<dependency>
    <groupId>xxxxxxxx</groupId>
    <artifactid>xxxxxxx</artifactid>
    <version>2.0</version>
    <scope>system</scope>
    <systemPath>${project.basedir}/src/main/resources/lib/xxxxxx-2.0.jar</systemPath>
</dependency>

在plugins中添加 plugin 如:
<plugin>
    <groupid>org.springframework.boot</groupId>
    <artifactid>spring-boot-maven-plugin</artifactid>
    <configuration>
        <includeSystemScope>true</includeSystemScope>
    </configuration>
</plugin>

项目库文件路径要准确,eclipse下把项目导出,tomcat发表项目

如图

图片说明
图片说明
图片说明图片说明