我在使用IDEA建web项目时,必须要把一些用到的JAR包导入到tomcat安装目录下才能正常运行,如何才能将JAR包导入到WEB-INF下的lib中,而不需要将JAR包导入tomcat的安装目录中.我每次导入JAR包,都不会再WEB-INF的lib中显示.
3条回答 默认 最新
关注
那是因为 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>
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 3无用 6