Causes
The war packages that were originally run in Tomcat were built using maven and rely on maven to manage. Now they need to connect with third-party systems and use third-party technology. The third-party provides several jar packages. When using them, they directly put these jar packages in the lib directory. When packaging, they found a ClassNotFundException and could not be found.
Solution
Make it into a jar package and add it to the pom file:
<build> <plugins> <plugin> <groupId></groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.6.0</version> <configuration> <source>1.8</source> <target>1.8</target> <encoding>UTF-8</encoding> <compilerArguments> <extdirs>${}/src/main/webapp/WEB-INF/lib</extdirs> </compilerArguments> </configuration> </plugin> </plugins> </build>
Make it into a war package and add it to the pom file:
<build> <plugins> <plugin> <groupId></groupId> <artifactId>maven-war-plugin</artifactId> <configuration> <webResources> <resource> <directory>${}/src/main/resources/lib</directory> <targetPath>WEB-INF/lib/</targetPath> <includes> <include>**/*.jar</include> </includes> </resource> </webResources> </configuration> </plugin> </plugins> </build>
The war package is formed, and the solution is to add it to the pom:
<build> <resources> <resource> <directory>${}/src/main/webapp/WEB-INF/lib</directory> <targetPath>WEB-INF/lib/</targetPath> <resource> </resources> </build>
This is the article about the solution to the jar package in the lib directory of maven packaging. For more related content on maven packaging and jar package, please search for my previous articles or continue browsing the related articles below. I hope everyone will support me in the future!