Build maven project with myeclipse

        Tool: myeclipse2013 System: windows10

        Some time ago, I wrote a project to start doing something regularly through the main method. It is a project jar package exported through eclipse, but the relevant jar packages referenced by the project are copied to the lib one by one, and then the corresponding directory is deployed and configured. MANIFEST.MF file, don't say baby is low, baby can't do anything either! I have never written this method of running the main method in a jar through a bat script. The last time I wrote the main method was the tank battle I did when I was in school, but it was packaged into an executable exe with a tool, and no jar was referenced. I haven't built a maven project myself for a long time. Recently, I happened to look at the configuration of using maven to package the main method and multiple modules. I suddenly remembered that I can replace my web project with a maven project, so that it can be automatically packaged into a zip package. After decompression You can deploy and run (of course, you have to write the script to run it yourself), you don't need to manually copy the lib package yourself, and you don't need to configure MANIFEST.MF yourself.

1. Start work directly

           Under normal circumstances, after creating a new maven project, the basic directory will exist and can be used directly, but that is not in this discussion. Create a new java project directly in myeclipse, and then build your own maven corresponding to src/main/java, src/main/resources, and webapp. Then configure the pom.

2. Convert WEB

           Some people here may not know how to configure the WEB-INFO directory under webapp. There are two methods. The first is to directly build a web project and move the contents to the webapp; the second is to convert the current java project into a web project and move the corresponding files to the webapp. When converting, you can right-click on the project, select Properties""Project Facets"""Dynamic Web Module"""Click ok to generate the corresponding WebRoot directory, remove the WEB-INFO and delete it. As shown below:

 

3. Convert Maven

   Some tools may not open the configuration of the project right-click Configure, first open the configuration: windows" "preferences" below:

 

Then you can see Configure""Conver to Maven Project" in the right-click list of the project. After clicking, it will associate the Maven plugin and convert it to a Maven project.

Fourth, modify the directory structure

            After converting to a maven project, the directory structure may not be the same as you usually see. It needs to be configured: Build Path" "Configure Build Path"" as shown below:

 delete the previous one, and then Add Folder corresponds to the directory structure. So far the maven project is built.

 

Fourth, talk about multi-module

         At present, I use myeclipse to create a maven project directly to create a submodule"" select create a simple project, and then the next step is as shown in the figure:

 

 Note that the parent module is packaged as pom, and then right-clicking on the parent project to create a Maven Module is basically no problem. When creating a Module submodule, you can choose create a simple project""next and then choose packaging as war, so that there will be a WEB-INFO directory under the webapp, of course, you can also choose not to create a simple .. , then you can follow the next Selecting the type maven-archetype-webapp has the same effect.

 

PS: If you want to create a multi-module maven project, guess I will tell you to use idea! ! The idea is good, who knows who uses it! ! !

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326724166&siteId=291194637