使用eclipse+maven+springBoot搭建简单的web项目,整合jsp,用控制器访问页面
首先打开eclipse,
点击File
选择New-Maven Project
点击Next
选择webapp,Next
输入Group Id和Artifact Id
然后Finish创建项目
创建完成时项目会报错(原因没有tomcat的运行环境)
解决方法:
右键项目-Build Path-Configure Build Path…
选择Add Add Library,加上tomact运行环境
如果这里没有tomact,往下看有解决方法:
如果如下图JRE环境不是自己的,最好也换成自己的
选择JRE System Library,Remove,然后Add Library,加上自己环境的jdk
Apply and Close,项目不报错了。
如果什么选择时没有tomact:
如果上面按步骤没有看到jdk和tomact,说明你的编辑器现在的工作环境,没有配置。请下载对应版本的jdk和tomact。然后Windows - Preferences
然后Server - Runtime Environments - Add
选择对应版本的tomact,Next
Browse,找到电脑里安装的tomact路径,然后Finish。
jdk也是同样的方法,java - Installed JRES - Add
继续,右键webapp - Build Path - Use as Source Folder,把webapp变成资源文件,以便项目加载
然后pom.xml加入如下配置
<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.jzj</groupId>
<artifactId>bootWeb</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>bootWeb Maven Webapp</name>
<url>http://maven.apache.org<