Linux uses IDEA configuration maven web project framework archetype (template) custom skeleton

Description : This skeleton is said archetype, it can also be understood as a template, a word that refers to the basic configuration when you create a project.

Introduction : When you create a web project using maven IDEA, are generally used as the default web project, as

However, after creation, the whole project is almost always the default configuration, nothing.

So the question is, (the premise is to use maven) if I can create a web project framework ssm as a template, and then later

Direct pressing this template to create it? In this case it does not always modify web.xml, pom.xml these things, they do not each addition

Ssm various configuration files. The answer is yes. Methods as below:

1, build a good basic project skeleton

Above is my favorite skeleton, mainly some configuration files and web.xml, pom.xml content

Are not generated, the generated resource file folder only, I did not learn the system maven, so do not know the specific reason.

However, even these configuration files already meet my needs, at least not every time you want to train for the demo to be reconfigured ssm

2. Use the maven command to create skeletons

After a good step to build a skeleton, you need to create a maven archetype (skeleton), that is, generate a number of related things, such as jar package.

(Ie the project in the root directory of the project pom.xmlto the next file's directory) mavencommand:

 mvn archetype:create-from-project 

Then create successful, as shown below

3. maven command to install backbone

In the root directory of the archetype (ie:  项目根目录\target\generated-sources\archetype) and then execute the following mavencommand:

  mvn install 

This put the archetype installed to the local maven repository

error:

However, I encountered a little problem, I forgot wrong shot, anyway, that is not found in the repository directory,

No such file or directory

If you encounter this problem, do not panic, it is because the warehouse does not create the folder.

The name of the folder should be the value of groupId. Once created, it can again execute maven install the installation was successful.

4. Use archetype

Maven can use the command line, but it is used herein IDEA.

When you see a skeleton that you install in your maven repository After that, you can add archetype in the IDEA.

Add the following manner

When you create a maven project, select the Create from archetype , then click on Add Archetype

After you fill in the pop-up window of groupId, artifactId, version on it.

Then select the template you just created, you can create success.

supplement:

1, range

According to the above method to create the skeleton, usually your local computer use, which means that if people want to use, you need to use another method.

Here it is not elaborated.

2, remove the skeleton

When you do not want to use this framework or skeleton wrong time, you need to delete, how to delete it? The main thing is to remove the two places.

Proceed as follows:

(1) Delete the skeleton IDEA

The main is to delete the contents of UserArchetypes.xml file. Location is not the same for different operating systems.

Mac System :

Generally in the $ {...} /. IntelliJIdea2018.3 / Maven / Indices / UserArchetypes.xml

Linux systems :

Generally in the $ {...} /. IntelliJIdea2018.3 / system / Maven / Indices / UserArchetypes.xml

Windows systems :

Generally in the $ {...} /. IntelliJIdea2018.3 / system / Maven / Indices / UserArchetypes.xml

$ {...} means that your installation path, mainly to you

主要就是这个路径下有个UserArchetypes.xml文件,然后打开删除里面的<archetype>标签即可

(2)删除maven仓库中的骨架

直接在你的本地仓库中按照你创建的骨架的groupId、artifactId寻找,之后删除文件夹即可。

比如我这里是直接删掉my文件夹就行了。

3.骨架命名

你的自定义骨架的groupId千万不要跟常见的名词重复,不然就会哭到爆。

命名是以这个来的  groupId、artifactId、version

比如我的骨架是groupId是my

然后我就用这个骨架新建项目,然后我就填一般的groupId和artifactId。

也就是说 你的自定义骨架是my.yellow-archetype

你用这个骨架创建的项目是cn.test

你就会发现你创建的项目里面,所有出现mybatis的词的地方,都变成了cnbatis

所以综上所述,把你的groupId命名为乱七八糟就行了,比如asdfghjjjkkll

Guess you like

Origin www.linuxidc.com/Linux/2019-07/159622.htm