How can I solve the problem of abnormal running of maven eclipse plug-in?

Source: Internet
Author: User
Tags maven central

Recently, I started a new java source code analysis tool, where I used eclipse's jdt to directly analyze the java source code. After the org. eclipse. jdt. core package is added with maven, it is found that the code cannot be run after it is written, and some dependencies cannot be found. It seems that the jdt downloaded from the maven central repository and its dependent packages both have minor version numbers, this write package cannot be found in maven dependency management (you do not know why the package can be downloaded but cannot be added to the dependency ). The specific situation is described in the same way.

After searching for a long time, I found that maven eclipse has a very powerful function, that is, to install all the plug-ins in the eclipse directory to the maven local repository, this method is used to solve the problem where maven dependency cannot be found. The specific command is as follows:

Mvn eclipse: make-artifacts-DstripQualifier = true-DeclipseDir = PATH_TO_ECLIPSE

In this way, jdt3.6 (used by eclipse helios) is installed locally and then in the pom of the project. -DstripQualifier = true is used to remove the minor version number starting with v when installing it to the local repository.

With this method, you can use the mvn command in the command line to package, but you can find another problem. When debugging in eclipse, the maven plug-in eclipse, although the locally installed jdt core is used, the subsequent dependency parsing still uses a jar package with a small version number and is automatically downloaded from the official maven remote repository. However, the tragedy is that these jar packages do not pass digital verification (it should not be a download error). During execution, java is thrown. lang. securityException: an exception such as Invalid signature file digest for Manifest main attributes. Use jarsigner-verify xxx. jar in the command line.

After verification, it is impossible to pass the verification, and the locally installed jar package verification is successful. The simplest method is to replace it with a local jar package without a small version number. However, there is still a problem in eclipse execution. Finally, I checked the dependency plug-in of maven, the copy dependency feature of this plug-in can be used to manually solve this problem. The process is as follows:

Create another lib folder under the Project directory
Run the mvn dependency: copy-dependencies-DoutputDirectory = lib command to copy all dependencies to the lib directory.
In eclipse, delete all maven-managed dependencies and manually add all jar packages in the lib directory.

Through this process, we can find that the jar packages directly copied by using the mvn command are locally installed without minor version numbers, which indicates that the maven plug-in eclipse is still a bit problematic.

Of course, if you want to execute the main method in the project, you can also use: mvn dependency: build-classpath to list all the directories of the jar packages currently dependent, then, use the java command to set these jar packages to classpath.

Related Article

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.