都说springboot方便,刚学习发现着实方便。小记一下入门学习过程。
example1:demo
1、首先按照网上的案例,创建初始化demo
2、启动demo,竟然报错
Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.
网上提供的解决办法是修改成
@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)
作用是关闭自动配置,去扫描特定的类而不是全部类
3、启动后访问本地8080端口即可
example2:整合mybatis
在demo基础上使用MVC框架整合mybatis,目录结构如下
与前期spring使用类似,bean,mapper,service,controller
配置文件中配置数据源
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/demo?useUnicode=true&characterEncoding=utf-8
spring.datasource.username=root
spring.datasource.password</