简体   繁体   中英

Converting an existing Java project to Maven in vscode

I have this old Java project without anything, I want to use maven with it because some dependencies are missing and I can't find the libs.
Can someone tell me how to convert that project to maven WITH VSCODE .

Here are some steps:

  1. Tell VS Code to use Maven .
  2. Add a pom.xml to your project to spell out the dependencies.
  3. Ask Maven to download the dependencies to your local .m2 repository.
  4. Use the Maven lifecycle to compile/test/package your code.

You'll have no problem as long as all the JARs you need are in Maven Central. If some of them were internal to your organization you'll have to find them and pull them from a private repo or add them to your local .m2.

If this is an old Java project you might want to think about updating. Check the JARs for security vulnerabilities and upgrade them if you can. Hopefully there will be a good Junit suite to prove that upgrades didn't break your code.

One last suggestion: Try to compile and run it on a LTS version of the JDK - 11 or 17. Don't continue with JDK 8 - it's past the end of its support life.

This is easy in IntelliJ. I'd prefer it to VS Code.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM