1.在创建好springboot maven项目之后,在controller中无法使用@requestmapping 注解。
因为缺少了 spring-web.jar包。需要在pom.xml中引入以下代码:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
引入之后,对该项目进行update 待包下载完毕,注解可以使用。如下
package com.test.simaple.contoller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
@RequestMapping("/")
public class HelloController {
@RequestMapping("/getHello")
public String getHello(){
return "";
}
}