SpringBoot

背景介绍

简化配置,更简单的使用spring和第三方软件

springboot官网介绍可以看出springboot的特点

Features

  • Create stand-alone Spring applications/一站式的spring使用

  • Embed Tomcat, Jetty or Undertow directly (no need to deploy WAR files)/整合了tomcat等容器

  • Provide opinionated 'starter' dependencies to simplify your build configuration/使用starter简化配置

  • Automatically configure Spring and 3rd party libraries whenever possible/自动装配spring和第三方

  • Provide production-ready features such as metrics, health checks and externalized configuration/准生产级别的监控等等

  • Absolutely no code generation and no requirement for XML configuration/没有code生成,没有xml配置

3.常见问题

1)springboot联合mybatis配置文件

2)自动注入时could not autowired

3)springboot测试

4.解决方案

1)在创建时选择mybaits,或者在pom中添加mybatis的starter,

<dependency>
    <groupId>org.mybatis.spring.boot</groupId>
    <artifactId>mybatis-spring-boot-starter</artifactId>
    <version>1.3.2</version>
</dependency>

在application.properties(或yml)中添加mybatis和datasourse的配置

mybatis.mapper-locations=classpath:*.xml

spring.datasource.driver-class-name=
spring.datasource.url=
spring.datasource.username=
spring.datasource.password=

注意名字不要选择错误 这样就完成了基本配置

2)自动注入时could not autowired

会提示错误,但并不影响运行,如果要修改的话,可以使用构造方法注入,或者在原类上添加@component注解

3)springboot测试

springmvc需要加载上下文才能进行某些测试,springboot测试变得简单只需要添加两个注释即可运行spring测试

@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest

5.编码实战

6.扩展思考

springboot页面制作及其他如redis等等的结合,将springboot用于实战     

7.参考文献

博客:纯洁的微笑  

http://www.ityouknow.com/spring-boot.html

8.更多讨论

springboot和springcloud结合使用

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值