- 建立一個 spring boot admin 的 server 端程式
buildscript {
ext {
springBootVersion = '1.5.10.RELEASE'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
group = 'idv.steven'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
configurations.all {
exclude group: 'log4j', module: 'log4j'
exclude group: 'org.slf4j', module: 'slf4j-log4j12'
exclude group: 'org.slf4j', module: 'log4j-over-slf4j'
exclude group: 'ch.qos.logback', module: 'logback-core'
exclude group: 'ch.qos.logback', module: 'logback-classic'
}
ext {
springBootAdminVersion = '1.5.7'
log4j2Version = '2.10.0'
}
dependencies {
compile('de.codecentric:spring-boot-admin-starter-server')
compile('de.codecentric:spring-boot-admin-server-ui')
compile group: 'org.apache.logging.log4j', name: 'log4j-api', version: "${log4j2Version}"
compile group: 'org.apache.logging.log4j', name: 'log4j-core', version: "${log4j2Version}"
compile group: 'org.apache.logging.log4j', name: 'log4j-slf4j-impl', version: "${log4j2Version}"
testCompile('org.springframework.boot:spring-boot-starter-test')
}
dependencyManagement {
imports {
mavenBom "de.codecentric:spring-boot-admin-dependencies:${springBootAdminVersion}"
}
}
- 設定 port
server.port=8081
- 執行 server
接下來要來看一下 client 程式怎麼修改,可以讓這個 server 進行監控。
- 修改 client 程式的 build.gradle
buildscript {
ext {
springBootVersion = '1.5.10.RELEASE'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
apply plugin: 'java'
apply plugin: 'war'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
group = 'idv.steven'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
configurations.all {
exclude group: 'log4j', module: 'log4j'
exclude group: 'org.slf4j', module: 'slf4j-log4j12'
exclude group: 'org.slf4j', module: 'log4j-over-slf4j'
exclude group: 'ch.qos.logback', module: 'logback-core'
exclude group: 'ch.qos.logback', module: 'logback-classic'
}
ext {
springBootAdminVersion = '1.5.7'
log4j2Version = '2.10.0'
}
dependencies {
compile('org.springframework.boot:spring-boot-starter-data-jpa')
compile('org.springframework.boot:spring-boot-starter-web')
compile('org.springframework.boot:spring-boot-starter-thymeleaf')
compile('de.codecentric:spring-boot-admin-starter-client')
compile group: 'org.apache.logging.log4j', name: 'log4j-api', version: "${log4j2Version}"
compile group: 'org.apache.logging.log4j', name: 'log4j-core', version: "${log4j2Version}"
compile group: 'org.apache.logging.log4j', name: 'log4j-slf4j-impl', version: "${log4j2Version}"
compile group: 'org.mariadb.jdbc', name: 'mariadb-java-client', version: '2.2.1'
compile group: 'javax.inject', name: 'javax.inject', version: '1'
compileOnly('org.projectlombok:lombok')
testCompile('org.springframework.boot:spring-boot-starter-test')
}
dependencyManagement {
imports {
mavenBom "de.codecentric:spring-boot-admin-dependencies:${springBootAdminVersion}"
}
}
- 修改 application.properties (client)
spring.boot.admin.url=http://localhost:8081 spring.boot.admin.client.name=demo endpoints.sensitive=false endpoints.logfile.external-file=d:/tmp/demo.log
- 執行 client



沒有留言:
張貼留言