1.新建一个controller包,新建一个test测试类,使用@RestController进行注解,表示是一个controller,使用注解@RequestMapping设置请求路径,点击运行项目中springbootboot启动类,如图则表示启动成功
然后在网页中输入http://localhost:8080/hellow 即可访问到此方法,
@RestController
public class test {
@RequestMapping(value = "/hellow")
public String hellow(){
return "hellow sprinboot";
}
}
显示结果如图:
注:有的同学运行时可能会报如下错误
APPLICATION FAILED TO START
Description:
Failed to configure a DataSource: ‘url’ attribute is not specified and no embedded datasource could be configured.
Reason: Failed to determine a suitable driver class
此时只需要给你的application加上
@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)即可
如下代码所示:
@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)
public class FootdemoApplication {
public static void main(String[] args) {
SpringApplication.run(FootdemoApplication.class, args);
}
}
接下来这篇文章将进行springboot+mybatis框架的配置,链接:https://blog.youkuaiyun.com/qq_20489601/article/details/81335281