这篇文章主要给大家介绍了关于spring boot创建和数据库关联模块的相关资料,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
创建步骤
1.导入依赖
2.配置文件
3.创建启动类
1.导入依赖
org.springframework.cloudspring-cloud-starter-o<b style="color:transparent">来源gao@!dai!ma.com搞$$代^@码!网</b>penfeignprovided javax.persistencepersistence-api1.0compile org.springframework.cloudspring-cloud-starter-netflix-eureka-client<!--自定义公共模块,可见公共模块文章--> com.xxcommon_db1.0-SNAPSHOT com.xxservice_goods_api1.0-SNAPSHOT
2.配置文件
server: port: 9011 spring: application: name: goods datasource: driver-class-name: com.mysql.jdbc.Driver url: jdbc:mysql://192.168.200.128:3306/goods?useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTC username: root password: root eureka: client: service-url: defaultZone: http://127.0.0.1:6868/eureka instance: prefer-ip-address: true feign: hystrix: enabled: true #hystrix 配置 hystrix: command: default: execution: timeout: #如果enabled设置为false,则请求超时交给ribbon控制 enabled: true isolation: strategy: SEMAPHORE
3.创建启动类
@SpringBootApplication @EnableEurekaClient //@MapperScan是tk.mybatis.spring.annotation包下的,用于扫描Mapper接口* @MapperScan(basePackages = {"com.goods.dao"}) public class GoodsApplication { public static void main(String[] args) { SpringApplication.run(GoodsApplication.class); } }
总结
到此这篇关于spring boot创建和数据库关联模块的文章就介绍到这了,更多相关springboot创建数据库关联模块内容请搜索gaodaima搞代码网以前的文章或继续浏览下面的相关文章希望大家以后多多支持gaodaima搞代码网!
以上就是spring boot创建和数据库关联模块详解的详细内容,更多请关注gaodaima搞代码网其它相关文章!