新建maven项目改servlet3.0配置
新建maven的web项目时,默认都是servlet2.3。想改成3.0,见以下步骤:
1.POM文件修改:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.along.studio</groupId> <artifactId>test-hibernate</artifactId> <packaging>war</packaging> <version>0.0.1-SNAPSHOT</version> <name>test-hibernate Maven Webapp</name> <url>http://maven.apache.org</url> <properties> <java-api.version>1.8</java-api.version> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <spring.version>4.1.1.RELEASE</spring.version> <hibernate.version>5.1.0.Final</hibernate.version> <mysql.connector.version>5.1.16</mysql.connector.version> </properties> <dependencies> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <version>1.16.6</version> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.12</version> <scope>test</scope> </dependency> </dependencies> <build> <finalName>hibernate</finalName> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.5.1</version> <configuration> <compilerVersion>${java-api.version}</compilerVersion> <source>${java-api.version}</source> <target>${java-api.version}</target> <encoding>${project.build.sourceEncoding}</encoding> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-source-plugin</artifactId> <version>2.4</version> <configuration> <attach>true</attach> </configuration> <executions> <execution> <phase>compile</phase> <goals> <goal>jar</goal> </goals> </execution> </executions> </plugin> </plugins> </build> </project>
2.web.xml
<?xml version="1.0" encoding="UTF-8"?> <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="hibernate" version="3.0"> <display-name>Archetype Created Web Application</display-name> </web-app>
3.项目下settings文件夹中的org.eclipse.wst.common.project.facet.core.xml打开
<?xml version="1.0" encoding="UTF-8"?> <faceted-project> <fixed facet="wst.jsdt.web"/> <installed facet="java" version="1.8"/> <installed facet="jst.web" version="3.0"/> <installed facet="wst.jsdt.web" version="1.0"/> </faceted-project>
4.javabuildpath:
addlibrary——Serverruntime——tomcat
以上修改完之后,maven-updateproject,再install一下,就ok了
相关推荐
Kafka 2020-09-18
Wepe0 2020-10-30
杜倩 2020-10-29
windle 2020-10-29
minerd 2020-10-28
mengzuchao 2020-10-22
Junzizhiai 2020-10-10
bxqybxqy 2020-09-30
风之沙城 2020-09-24
kingszelda 2020-09-22
大唐帝国前营 2020-08-18
yixu0 2020-08-17
TangCuYu 2020-08-15
xiaoboliu00 2020-08-15
songshijiazuaa 2020-08-15
xclxcl 2020-08-03
zmzmmf 2020-08-03
newfarhui 2020-08-03
likesyour 2020-08-01