How do I get maven to copy a project-dependent jar into the Web-inf/lib directory?
Source: Internet
Author: User
Scenario: When it comes to MAVEN web development, the dependency jar is not placed under Src/main/webapp/web-inf/lib, which is not the same as when we used the Eclipse development tool to do web development, How to be able to compile at the time can only rely on the jar package copy to the corresponding Lib directory. Technical keywords: How to perform the corresponding goal at a certain stage of the corresponding life cycle
1. Execute the maven-dependency-plugin:copy-dependencies command at the compile phase of the default lifecycle: <plugin> <groupId>org.apache.maven.plugins</groupId> < artifactid>maven-dependency-plugin</artifactid> <executions> <execution> <id>install </id> <phase>install</phase> <goals> <goal>sources</goal> </goals> </ execution> <execution> <id>compile</id> <phase>compile</phase> <goals> < goal>copy-dependencies</goal> </goals> <configuration> <outputdirectory>src/main/ webapp/web-inf/lib</outputdirectory> </configuration> </execution> </executions> </ Plugin> 2. When the dependent jar package changes, you should perform a clean lifecycle, removing all old jar packages, so that the Web-inf/lib and Maven's dependency management jar packs are consistent. <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactid>maven-clean-plugin</ Artifactid> <executions> <execution> <id>clean</id> <phase>pre-clean</phase> <goals> <goal> clean</goal> </goals> <configuration> <directory>src/main/webapp/web-inf/lib</ directory> </configuration> </execution> </executions> </plugin>
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.