创建SpringMVC项目helloworld(由maven项目导入springmvc框架)

   声明:本站部分内容来自互联网,如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。

27

1、新建maven项目
maven home path:
D:/Software/Maven/apache-maven-3.8.1
user settings file:
D:SoftwareMavenpache-maven-3.8.1confsettings.xml
2、导入springmvc框架
add framework support
spring - springmvc
3、run - edit configurations - tomcat server - local - employment - add artifact - artifact:MavenSpringMVC_demo:war exploded (注意employment点选后缀是exploded的项目)
4、file - project structure - atifacts - artifact:MavenSpringMVC_demo:war exploded(尤其注意要选带有exploded后缀的选项) - output layout - available elements - 点选项目右键 - put into output root
至此,项目可以运行,如果还是运行报错,尝试下面第五、六步!
5、在pom.xml中加入以下依赖,导入spring相关jar包(记得maven项目那里重新加载一下,还有再点击一下put into output root,重启啥的多试试)

<dependency><groupId>org.springframeworkgroupId><artifactId>spring-coreartifactId><version>5.2.3.RELEASEversion>
dependency>
<dependency><groupId>org.springframeworkgroupId><artifactId>spring-webmvcartifactId><version>5.2.3.RELEASEversion>dependency>

6、另外注意下面这个地方由1.7改为1.8

<properties><project.build.sourceEncoding>UTF-8project.build.sourceEncoding><maven.compiler.source>1.8maven.compiler.source><maven.compiler.target>1.8maven.compiler.target>properties>

原文链接