spring boot

如何学习spring boot   https://www.zhihu.com/question/53729800

创建maven项目   https://www.cnblogs.com/tenglongwentian/p/5564359.html

spring boot 之HelloWorld


spring boot 整合mybatis项目报错

1.在application的启动文件类上加@ComponentScan注解,扫描控制器的路径,@mappersan扫描mapper文件的路径,开始的时候是这样写的@ComponentScan(basePackages="com.test.controllerPack1")    @MapperScan("com.test.dao")报错

Field testService in com.test.controllerPack1.MybatisTest required a bean of type 'com.test.service.TestService' that could not be found.
Action:
Consider defining a bean of type 'com.test.service.TestService' in your configuration.

将控制器扫描改为com.test.* 正常启动 

@SpringBootApplication注解,相当于@componentScan和@EnableAutoConfiguration和@configuration注解,只作用于启动类的统计包以及下级,对上级无效,所以可以去掉conponentScan然后将启动类移到控制器的上层启动。



2.在mapper.xml中写sql语句,项目报错java.lang.NoSuchMethodException: com.test.dao.TestDao.<init>()

以及错误无法找到对应的类里面的方法,将sql语句放在dao文件中项目正常启动@select("select * from user where id=1")

3.修改maven项目的树状结构


4.导入项目上有红叉,但是类文件上没有,检查java Compiler和project facets里的java版本是否一致。记得maven-->update project。

5.springBoot启动报错

Exception in thread “main” org.springframework.context.ApplicationContextException: Unable to start embedded container;

pom文件中添加web依赖包即可。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值