解决maven web项目Cannot detect Web Project version. Please specify version of Web Project through...的错误

没有用骨架模板,创建maven web工程后会出现如下的错误,在pom.xml文件头部 有以下的错误

Cannot detect Web Project version. Please specify version of Web Project through <version> configuration property of war plugin. E.g.: <plugin> <artifactId>maven-
 war-plugin</artifactId> <configuration> <version>3.0</version> </configuration> </plugin>

解决方法如下:

在pom.xml文件中加入:

    <build>
		<plugins>
			<plugin>
				<artifactId>maven-compiler-plugin</artifactId>
				<configuration>
					<source>1.7</source>
					<target>1.7</target>
				</configuration>
			</plugin>
			<plugin>
				<artifactId>maven-war-plugin</artifactId>
				<version>2.4</version>
				<configuration>
					<version>3.0</version>
				</configuration>
			</plugin>
		</plugins>
		<finalName>webserver</finalName>
	</build>

注意:加入的maven-compiler-plugin可以让编译的水平不会是J2SE1.5的水平,加入的maven-war-plugin可以去生成index.jsp和web.xml文件(这是没用骨架模板的情况)

猜你喜欢

转载自blog.csdn.net/u012060033/article/details/82768000