spring boot创建和数据库关联模块详解
创建步骤
1.导入依赖
2.配置文件
3.创建启动类
1.导入依赖
org.springframework.cloud spring-cloud-starter-openfeign provided javax.persistence persistence-api 1.0 compile org.springframework.cloud spring-cloud-starter-netflix-eureka-client com.xx common_db 1.0-SNAPSHOT com.xx service_goods_api 1.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"}) publicclassGoodsApplication{ publicstaticvoidmain(String[]args){ SpringApplication.run(GoodsApplication.class); } }
总结
到此这篇关于springboot创建和数据库关联模块的文章就介绍到这了,更多相关springboot创建数据库关联模块内容请搜索毛票票以前的文章或继续浏览下面的相关文章希望大家以后多多支持毛票票!
声明:本文内容来源于网络,版权归原作者所有,内容由互联网用户自发贡献自行上传,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任。如果您发现有涉嫌版权的内容,欢迎发送邮件至:czq8825#qq.com(发邮件时,请将#更换为@)进行举报,并提供相关证据,一经查实,本站将立刻删除涉嫌侵权内容。