您好,登錄后才能下訂單哦!
今天就跟大家聊聊有關spring boot創建和數據庫關聯模塊,可能很多人都不太了解,為了讓大家更加了解,小編給大家總結了以下內容,希望大家根據這篇文章可以有所收獲。
1.導入依賴
<dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-openfeign</artifactId> <scope>provided</scope> </dependency> <dependency> <groupId>javax.persistence</groupId> <artifactId>persistence-api</artifactId> <version>1.0</version> <scope>compile</scope> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId> </dependency> <!--自定義公共模塊,可見公共模塊文章--> <dependency> <groupId>com.xx</groupId> <artifactId>common_db</artifactId> <version>1.0-SNAPSHOT</version> </dependency> <dependency> <groupId>com.xx</groupId> <artifactId>service_goods_api</artifactId> <version>1.0-SNAPSHOT</version> </dependency> </dependencies>
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創建和數據庫關聯模塊有進一步的了解嗎?如果還想了解更多知識或者相關內容,請關注億速云行業資訊頻道,感謝大家的支持。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。