Eclipse uses maven to create a web project process

The process of creating a web project in maven


( The eclipse used is Eclipse Jee Oxygen, the JDK version is 1.8, and the maven version is 3.5.2 )


  1. Use eclipse to create a new maven project:
  2. Project structure:
  3. After the project is created, if there is an error in the JSP file generated by the project, the project is missing the jar package related to the servlet, and the following dependencies should be added to the generated pom.xml file:
<dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>3.0.1</version>
            <scope>provided</scope>
</dependency>

PS: The default jdk version of the maven project created by eclipse may be different from the version installed on your own computer. At this time, there will be a small red exclamation mark on the icon of the project. The solution is to right-click the project and find the buildpath to add your own installed jdk library.
But in this way, every time you build a project, you have to change it again, and as long as the project is updated, it will be returned. The blogger recommends directly modifying the settings.xml in the maven conf directory, and adding the following statement in the profiles tag, here is the modification to JDK1. 8 version

<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>

settting.xml

The files of Gloobal Settings and User Settings should both exist and have the same content


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325485207&siteId=291194637