正文:
安装JDK、Eclipse、Maven,SpringBoot,MySQL Server,SQLyog
SpringBoot点击help->Eclipse Marketplace->search sts,click install
1、spring boot无法引入@RestController失败,提示找不到该注解
解: pom.xml少引入了一个web,添加中间的web依赖即可
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
2、项目启动,浏览器请求不到@RequestMapping自定义路径。
解:
1:创建的controller类与application启动类处于同一层级
2:或者自定义的controller在application的子包下
如图,已自定义controller.java, 若application.java在com.spring.demo包下,即使启动,浏览器也访问不到Democontroller,将application.java移动到父包即可。