1、创建java项目,点击File-New-Other-Maven Project,完成以上操作后,进入以下界面,点击next
2、下图的Catalog,第一次创建时,默认选中的是All Catalog,此时我们要改成Internal,然后下面的也要改成后缀名为webapp的,完成后点击next
3、来到这边,Group Id可填的是域名.公司名称;Artifact Id可填的是模块名称,填好后,点击finish就完成了
4、创建完成后,出来的项目是这样的,会有报错
5、选中项目,然后右键,点击最下面那个
6、找到以下图中标注的Project Facets
7、更改以下内容,正常的Dynamic Web Module是2.3,且为选中状态,我们改为3.0,把勾取消,下面Java改成1.8,完成以上操作后点击Apply应用,然后关闭
8、做完以上操作后,再次进入第七步的界面,勾选上Dynamic Web Module,然后下方会出现一段话
9、点击上一步出现的那句话,会出现以下界面
10、这里把WebContent更改为src/main/webapp,更改之后点击ok,之后回到第七部的界面,点击apply运行就行了
11、回到原始界面,找到web/inf下的web.xml,点击开来
12、修改web.xml2.3–》3.0,注意要覆盖掉第一个web-app
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="WebApp_ID" version="3.0">
13、pom.xml修改,1.7–》1.8
<build>
<finalName>strutsmaven</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
</plugins>
</build>
14、继续配置
<properties>
<servlet.version>4.0.1</servlet.version>
<junit.version>3.8.1</junit.version>
<MySql.version>5.1.44</MySql.version>
<jstl.version>1.2</jstl.version>
<hibernate.version>5.2.12.Final</hibernate.version>
</properties>
<dependencies>
<!-- servlet -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>${servlet.version}</version>
<scope>provided</scope>
</dependency>
<!-- junit -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<!-- MySQL -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${MySql.version}</version>
</dependency>
<!-- jstl -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>${jstl.version}</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>${hibernate.version}</version>
</dependency>
15、然后不报错了,基本就是配置完成了
白拜~