[Spring cloud 一步步實現廣告系統] 9. 主類和配置文件

搜索系統啓動主類

/**
 * AdSearchApplication for 廣告搜索服務啓動類
 *
 * @author <a href="mailto:magicianisaac@gmail.com">Isaac.Zhang | 若初</a>
 */
@EnableFeignClients  //啓動Feign 客戶端,爲了訪問其餘微服務
@EnableDiscoveryClient // 開啓服務發現組件,在這裏等同於 @EnableEurekaClient
@EnableHystrix // 開啓hystrix 斷路器
@EnableCircuitBreaker // 斷路器
@EnableHystrixDashboard // 開啓hystrix 監控
@SpringBootApplication
public class AdSearchApplication {
    public static void main(String[] args) {
        SpringApplication.run(AdSearchApplication.class, args);
    }
}

配置文件

server:
  port: 7001
  servlet:
    context-path: /ad-search #http請求的根路徑(請求前綴,在handle的mapping以前,須要127.0.0.1/ad-search/XXXX)
spring:
  application:
    name: mscx-ad-search
  jpa:
    show-sql: true #執行時是否打印sql語句,方便調試
    hibernate:
      ddl-auto: none
    properties:
      hibernate.format_sql: true
    open-in-view: false #控制是否在懶加載時,有可能會找不到bean報錯
  datasource:
    username: root
    url: jdbc:mysql://127.0.0.1:3306/advertisement?useSSL=false&autoReconnect=true
    password: ****
    tomcat:
      max-active: 4 #最大鏈接數
      min-idle: 2 #最小空閒鏈接數
      initial-size: 2 #默認初始化鏈接數
eureka:
  client:
    service-url:
      defaultZone: http://server1:7777/eureka/,http://server2:8888/eureka/,http://server3:9999/eureka/
feign:
  hystrix:
    enabled: true
management:
  endpoints:
    web:
      exposure:
        include: "*"

adconf:
  mysql:
    host: 127.0.0.1
    port: 3306
    username: root
    password: ****
    binlogName: ""
    position: -1
  kafka:
    topic: ad-search-mysql-data
相關文章
相關標籤/搜索