Is it possible to build a java project only once using eclipse and share?

前端 未结 5 1689
有刺的猬
有刺的猬 2020-12-01 16:51

Is it possible to actually build a maven project containing java code to be built once and the binaries can be shared?

Problem: The project I am trying to build woul

5条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-01 17:11

    Is it possible to actually build a maven project containing java code to be built once and the binaries can be shared?

    Yes, that's the whole point of Maven, you build the project once, thus generating an artifact (your jar/war ...) which is stored in your local maven repository.

    The following command build the project and save it in the local repo :

    mvn clean install 
    

    However, if you do this, you only have the artifact on your local repo.

    A good practise is to create a repository and store your artifacts over there : https://maven.apache.org/repository-management.html

    The use of the following command would store the snapshot dependency on the repository :

    mvn clean deploy
    

    You can then reuse your components through multiples computer by specifying the dependencies in your new project's pom.xml file.

    You might want to give a look at this guide :

    http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html

    You would obviously need to configure the repository and your maven project in order to use a setup of this kind.

提交回复
热议问题