Creating the Maven version of Java Web engineering and engineering

Foreword

Once installed and configured Maven, we will learn how to create the first version of Java Maven project and Web project in Esclipse in. (Maven installation and configuration may refer to related content: https://blog.csdn.net/TheWindOfSon/article/details/104066060 )

1. Prior to the new project, to be relevant settings in Eclipse Maven

(1) on the menu bar Windows-> Preferences-> Maven-> Installations-> Add ... (choose your own Maven installation directory)
Here Insert Picture Description
Here Insert Picture Description
Here Insert Picture Description
Here Insert Picture Description

(2) or Maven-> User Settings as follows in the same listHere Insert Picture Description

2. after the completion of the configuration to be a new version of Java Maven project of

(1) Click the right mouse button New -> Maven Project
Here Insert Picture Description
Tips: If you can not find the right New time this option can proceed as follows:
Here Insert Picture Description
Here Insert Picture Description
Here Insert Picture Description
Here Insert Picture Description
Here Insert Picture Description
Here Insert Picture Description
Tips: Run in the above manner Maven files are no problem, but some small partners want to use when your JRE, how to configure it?
Here are two ways to make changes, one is configured in Eclipse, but this needs to be configured once for each project;
another is related to the configuration of the conf directory in Maven / settings.xml file, this after all the items are able to use both its own version of the JRE.

1) The first way: perform configuration in Eclipse
, right-click the project Properties-> Java Build Path
Here Insert Picture Description
Here Insert Picture Description
Here Insert Picture Description
Here Insert Picture Description

Right-click the project Properties-> the Java Compiler
Here Insert Picture Description
2) (recommended) The second way: to find profiles Maven label under the conf directory under / settings.xml, and do the following configuration (JDK version uses its own version number)

<profile> 
		  <id>jdk-1.8</id>  
		  <activation>
			<activeByDefault>true</activeByDefault>
			<jdk>1.8</jdk>  
		  </activation>  
			
		  <properties>  
			<maven.compiler.source>1.8</maven.compiler.source>  
			<maven.compiler.target>1.8</maven.compiler.target>  
			<maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>  
		  </properties>   
		</profile> 

Here Insert Picture Description
Here Insert Picture Description
The final renderings:
Here Insert Picture Description
3. Create a new Web version of Maven Engineering
(1) Right-click New -> Maven Project
Here Insert Picture Description
Here Insert Picture Description
Here Insert Picture Description
if done the above steps, you think everything will be fine, it would be wrong. The back is the key

We will find a "X" on the project, how do we solve it?
Here Insert Picture Description
Steps: Right Project Properties-> Maven-> Project Facets
Here Insert Picture Description
between √ have it point out, the click Apply, and then step on the √, so there will be something to let you configure the
Here Insert Picture Description
Here Insert Picture Description
completion of the above steps, the project × disappeared, but also generates the web.xml file.
Here Insert Picture Description
Although the project is not being given, but we are still being given new jsp page, because we lack the runtime environment Server Runntime, then we can be configured via the pom.xml file can also be set directly solve the runtime environment.

(1) Here we introduce directly the runtime environment to solve
Here Insert Picture Description
Here Insert Picture Description
Here Insert Picture Description
Here Insert Picture Description

to sum up

Here is a new version of Maven Java Web engineering and process engineering of all the. It is more complicated, so most of my screenshot to show, if there is an error, please bigwigs promptly corrected.

Published 19 original articles · won praise 2 · Views 410

Guess you like

Origin blog.csdn.net/TheWindOfSon/article/details/104068011