Questions to IntellijIDEA and Maven

前端 未结 2 1012
南旧
南旧 2021-01-27 12:06

I have been working in XCode and with Objective-C in the last few years, but I knew that once I would have to transition to Eclipse or the like for Java projects. Case is, I do

相关标签:
2条回答
  • 2021-01-27 12:24

    in a Maven project you add your libraries you depend on in your pom.xml file, there is no need to add them somewhere else in your IDE and/or link them via the IDE to your project. just add a new dependency to your pom.xml file.

    maven stores (if not set otherwise) all the artifacts (libraries) in a folder: ~/.m2/, that is where you keep your dependencies, and which is your local maven repository.

    Maven makes your life easier as you do not have to add the jar's to your classpath anymore. make sure that your maven project is indeed recognized as a maven project by your IDE (usually it's a tiny M in your projects view).

    here is a short intro to maven, that helped me a lot in the beginning: http://maven.apache.org/guides/getting-started/maven-in-five-minutes.html , especially in order to understand the lifecycle.

    as you mentioned mvn install: the artifact you built will get deployed to your local maven repository, all other projects you have can make use of this artifact and will reference the latest artifact you deployed.

    you can run your project just as any other project, click on the run button and select your main class.

    if your project results in a runnable jar, you can also define it in your pom.xml file. see How can I create an executable JAR with dependencies using Maven? to create a jar containing all your dependencies/libraries in one jar, or How to create a runnable jar with maven that includes dependencies in a separate "lib" folder (not an uber jar) for a runnable jar which puts the deps/libs to a separate folder. anyway, in both cases the MANIFEST file (which is needed for an executable jar) will be generated by Maven appropriately.

    0 讨论(0)
  • 2021-01-27 12:37

    Try mvn idea:idea to generate project for IntellijIDEA from the maven's pom.xml. Then just open the project and see all the libraries added.

    0 讨论(0)
提交回复
热议问题