Maven project starts on tomcat in Eclipse, the problem of missing jar package

        Just sharing it because I couldn't find it. The following solutions are not found everywhere:

        Right-click the project->properties->find Deployment Assembly, and on the right is the configuration for compilation and packaging, to see if the dependencies of the lib library are missing. For me, click Add to add the maven dependency library. The final list is as follows.

        The above scheme, I looked at it myself, it is like this, no need to set it, reset it once, and it is invalid. The test error is an error when accessing jsp, which is roughly as follows:

        Errors like http://java.sun.com/jsp/jstl/core No corresponding description found in web.xml. Because my jsp has referenced this c tag from the beginning.

        After thinking about it, it should be that my eclipse project is accessed directly under tomcat in the form of a directory mapping project, and the biggest difference between this method and myeclipse is that it does not copy the webapps to tomcat after compiling the project as a whole under the directory. Then, when mapping, there must be a jar file in the WEB-INF/lib directory, otherwise, an error will be reported when accessing all related functions.

        Therefore, if the processing logic is passed first, the dependent jar will report the corresponding error because it cannot be found, and if the empty logic turns to jsp to run, it will report the error that the corresponding jar cannot be found in the tag library.

        Thinking of the above principle, then it's good to solve it. After looking for it, maven just has a relevant copy plug-in. In the plug-in part of pom.xml, the following code can be introduced:

<plugin> 
  <groupId>org.apache.maven.plugins</groupId>  
  <artifactId>maven-dependency-plugin</artifactId>  
  <executions> 
    <execution> 
      <phase>clean</phase>  
      <goals> 
        <goal>copy-dependencies</goal> 
      </goals>  
      <configuration> 
        <outputDirectory>src/main/webapp/WEB-INF/lib</outputDirectory>  
        <overWriteReleases>false</overWriteReleases>  
        <overWriteSnapshots>false</overWriteSnapshots>  
        <overWriteIfNewer>true</overWriteIfNewer> 
      </configuration> 
    </execution> 
  </executions> 
</plugin>

        The meaning of this code is to copy all the configured dependent jars directly to the lib directory of the project during the clean phase of executing maven. According to the meaning, clean the project and find that all the jars have passed, then add the project to tomcat and start accessing it. OK, everything is normal, the problem is solved.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324432563&siteId=291194637