Preparations for building Maven projects in Eclipse, and building maven in eclipse
Maven is an excellent Java project object model solution, meaning the accumulation of knowledge (Italian Xuwen). Maven can easily solve the Java project package dependency problem by configuring pom. xml introduces dependencies, and other dependencies are automatically introduced.
Operating system version: windows 7
Eclipse version: Oxygen.1a (4.7.1a)
Maven version: 3.5.2
JDK version: 1.8.0 _ 144-b01
Download JDK: http://www.oracle.com/technetwork/java/javase/downloads/index.html
Download MAVEN: https://maven.apache.org/download.cgi
Download Tomcat: https://tomcat.apache.org/download-90.cgi
Download Eclipse: http://www.eclipse.org/downloads/
Configure JDK
Install JDK to the directory (for example) D:/Java/and add the environment variable JAVA_HOME D: \ java \ jdk1.8.0 _ 144 PATH ...; % JAVA_HOME % \ bin;, run java-version and javac-version on the console, as shown below:
C: \ Users \ Polycarp> java-version
Java version "1.8.0 _ 144"
Java (TM) SE Runtime Environment (build 1.8.0 _ 144-b01)
Java HotSpot (TM) 64-Bit Server VM (build 25.144-b01, mixed mode)
C: \ Users \ Polycarp> javac-version
Javac 1.8.0 _ 144
Note that the Java installation path should not contain spaces according to some traditional statements. Prevent identification by third-party development tools.
Configure Maven
Decompress the maven Binary Package to (example) D:/Java/tool/, and create D: \ java \ tools \ maven-3.5.2-repository \ as the dependent package storage path, open D: \ java \ tools \ apache-maven-3.5.2 \ conf \ settings. xml to modify the content:
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"><localRepository>D:\java\tools\maven-3.5.2-repository</localRepository><pluginGroups>
The highlighted part is the original annotation content. Change to any local path to store various dependent packages.
<profiles><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></profiles>
Enter the above content in the profiles section.
Save the file. Run mvn help: system on the command line. If no ERROR is reported, the configuration is successful.
Note: It is best not to have spaces in the MAVEN installation path. Based on the traditional conservative approach, there is no space in the installation path. Although it is derived from ideology, it will share the same viewpoint in the post and will not be repeated.
Configure Tomcat
Decompress Tomcat to the specified folder (for example, D: \ java \ servers \ apache-tomcat-9.0.1 ).
Configure Eclipse
Open Eclipse, create a workspace, choose Windows> Preferences> Maven> User Settings, and select a file pointing to the Maven installation path (example) D in Global Settings and User Settings: \ java \ tools \ apache-maven-3.5.2. Click Update Settings. The effect is as follows:
By default, Eclipse has a problem in displaying Chinese characters, because it does not support the Chinese display mode when using the LAS las wide font. Therefore, Chinese is very small and ugly. You need to change the font to the Courier New font in the following way:
The default font list does not contain the Courier New font. You need to click the "show more fonts" hyperlink to enter the control panel, click show in the Courier New font, and close the control panel, the font is randomly displayed in the list.
Create a maven Project
Click File-> New-> Maven Project-> [Default options] Next-> [select the Artifact Id as the...-webapp option to create a web Project]-> Next->
- Group ID: org. ivanna. web. springbootproj
- Artifact ID: IvannaSpringBootProj
-> Finish
,
So far, the project has been created.
Solve JDK and WEB version Problems
Right-click the project and choose Properties> Java Build Path> Add Library...> Server Runtime> Apache> Tomcat 9.
Here, the author's JRE version is automatically 1.8. If not, delete the JRE System Library and re-Add the JRE (JDK) as described above ).
Open the project IvannaSpringBootProj-> Depolyed Resources-> webapp-> WEB-INF-> web. xml
The modification content is as follows:
<!DOCTYPE web-app PUBLIC"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN""http://java.sun.com/dtd/web-app_3_0.dtd" ><web-app><display-name>Archetype Created Web Application</display-name></web-app>
Pay attention to part of the Declaration.
So far, theoretically your project should have no error message.