第二章:启动springboot,输出 hellow springboot

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值