mirror of
https://gitee.com/wangkang/udf.git
synced 2026-10-29 23:43:40 +00:00
添加spring boot admin服务
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
########################################################
|
||||
###org.itkk.application.config (ApplicationConfig)
|
||||
########################################################
|
||||
org.itkk.application.config.outputExceptionStackTrace=true
|
||||
org.itkk.application.config.threadPool.poolSize=100
|
||||
########################################################
|
||||
###LOGGING (must reboot)
|
||||
########################################################
|
||||
logging.file=d:/develop/application-log/${spring.application.name}_${server.port}_${spring.profiles.active}/base.log
|
||||
########################################################
|
||||
###turbine ( TurbineProperties )
|
||||
########################################################
|
||||
turbine.appConfig=udf-admin-server
|
||||
########################################################
|
||||
###notify
|
||||
########################################################
|
||||
spring.boot.admin.notify.mail.from=udf_admin@163.com
|
||||
spring.boot.admin.notify.mail.to=udf_admin@163.com
|
||||
+2
-1
@@ -24,11 +24,12 @@
|
||||
<docker.java.base.image>192.168.1.10:5000/org.itkk/java:8</docker.java.base.image>
|
||||
<docker.registry.host>192.168.1.10:5000</docker.registry.host>
|
||||
<docker.maintainer>wangkangit@163.com</docker.maintainer>
|
||||
<spring-boot-admin.version>1.5.6</spring-boot-admin.version>
|
||||
<spring-boot-admin.version>1.5.7</spring-boot-admin.version>
|
||||
</properties>
|
||||
<!--子模块 -->
|
||||
<modules>
|
||||
<module>udf-eureka-config-server</module>
|
||||
<module>udf-admin-server</module>
|
||||
</modules>
|
||||
<!-- 环境 -->
|
||||
<profiles>
|
||||
|
||||
@@ -0,0 +1,114 @@
|
||||
<?xml version="1.0"?>
|
||||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<!-- maven坐标 -->
|
||||
<artifactId>udf-admin-server</artifactId>
|
||||
<name>udf-admin-server</name>
|
||||
<packaging>jar</packaging>
|
||||
<url>http://itkk.org:81</url>
|
||||
<!-- 父依赖 -->
|
||||
<parent>
|
||||
<groupId>org.itkk.udf</groupId>
|
||||
<artifactId>udf-server</artifactId>
|
||||
<version>1.0</version>
|
||||
</parent>
|
||||
<!-- 参数 -->
|
||||
<properties>
|
||||
<server.port>9002</server.port>
|
||||
<management.port>8002</management.port>
|
||||
</properties>
|
||||
<!-- 依赖 -->
|
||||
<dependencies>
|
||||
<!-- udf-starter-mail -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-mail</artifactId>
|
||||
</dependency>
|
||||
<!-- spring-boot-admin-server 服务器监控 -->
|
||||
<dependency>
|
||||
<groupId>de.codecentric</groupId>
|
||||
<artifactId>spring-boot-admin-server</artifactId>
|
||||
<version>${spring-boot-admin.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>de.codecentric</groupId>
|
||||
<artifactId>spring-boot-admin-server-ui</artifactId>
|
||||
<version>${spring-boot-admin.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>de.codecentric</groupId>
|
||||
<artifactId>spring-boot-admin-server-ui-turbine</artifactId>
|
||||
<version>${spring-boot-admin.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>de.codecentric</groupId>
|
||||
<artifactId>spring-boot-admin-server-ui-login</artifactId>
|
||||
<version>${spring-boot-admin.version}</version>
|
||||
</dependency>
|
||||
<!-- spring-cloud-starter-hystrix-dashboard 断路器-监控面板 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-turbine</artifactId>
|
||||
</dependency>
|
||||
<!-- spring-boot-starter-security -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-security</artifactId>
|
||||
</dependency>
|
||||
<!-- udf-starter-core -->
|
||||
<dependency>
|
||||
<groupId>org.itkk.udf</groupId>
|
||||
<artifactId>udf-starter-core</artifactId>
|
||||
</dependency>
|
||||
<!-- udf-starter-amqp-rabbitmq -->
|
||||
<dependency>
|
||||
<groupId>org.itkk.udf</groupId>
|
||||
<artifactId>udf-starter-amqp-rabbitmq</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<!-- 构建 -->
|
||||
<build>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>${project.basedir}/src/main/resources/</directory>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<!-- package -->
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<version>${springboot.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<!-- docker -->
|
||||
<plugin>
|
||||
<groupId>com.spotify</groupId>
|
||||
<artifactId>docker-maven-plugin</artifactId>
|
||||
<version>${docker-maven-plugin.version}</version>
|
||||
<configuration>
|
||||
<imageName>${docker.registry.host}/${project.groupId}/${project.artifactId}:latest</imageName>
|
||||
<baseImage>${docker.java.base.image}</baseImage>
|
||||
<maintainer>${docker.maintainer}</maintainer>
|
||||
<exposes>${server.port}</exposes>
|
||||
<cmd></cmd>
|
||||
<entryPoint>["java","-jar","/${project.build.finalName}.jar"]</entryPoint>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>${project.build.directory}</directory>
|
||||
<include>${project.build.finalName}.jar</include>
|
||||
</resource>
|
||||
</resources>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
package org.itkk.udf.admin.server.demo;
|
||||
|
||||
import de.codecentric.boot.admin.notify.MailNotifier;
|
||||
import de.codecentric.boot.admin.notify.Notifier;
|
||||
import de.codecentric.boot.admin.notify.RemindingNotifier;
|
||||
import de.codecentric.boot.admin.notify.filter.FilteringNotifier;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* 通知
|
||||
*/
|
||||
@Configuration
|
||||
@ConditionalOnBean(MailNotifier.class)
|
||||
@AutoConfigureAfter(de.codecentric.boot.admin.config.NotifierConfiguration.MailNotifierConfiguration.class)
|
||||
public class NotifierConfiguration {
|
||||
|
||||
/**
|
||||
* delegate
|
||||
*/
|
||||
@Autowired
|
||||
private Notifier delegate;
|
||||
|
||||
/**
|
||||
* filteringNotifier
|
||||
*
|
||||
* @return FilteringNotifier
|
||||
*/
|
||||
@Bean
|
||||
public FilteringNotifier filteringNotifier() {
|
||||
return new FilteringNotifier(delegate);
|
||||
}
|
||||
|
||||
/**
|
||||
* remindingNotifier
|
||||
*
|
||||
* @return RemindingNotifier
|
||||
*/
|
||||
@Bean
|
||||
@Primary
|
||||
public RemindingNotifier remindingNotifier() {
|
||||
final int duration = 10;
|
||||
RemindingNotifier notifier = new RemindingNotifier(filteringNotifier());
|
||||
notifier.setReminderPeriod(TimeUnit.SECONDS.toMillis(duration));
|
||||
return notifier;
|
||||
}
|
||||
|
||||
/**
|
||||
* remind
|
||||
*/
|
||||
@Scheduled(fixedRate = 60_000L)
|
||||
public void remind() {
|
||||
remindingNotifier().sendReminders();
|
||||
}
|
||||
|
||||
}
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
/**
|
||||
* UdfEurekaServerDemoApplication.java
|
||||
* Created at 2016-10-02
|
||||
* Created by wangkang
|
||||
* Copyright (C) 2016 itkk.org, All rights reserved.
|
||||
*/
|
||||
package org.itkk.udf.admin.server.demo;
|
||||
|
||||
import org.itkk.udf.core.BaseApplication;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.cloud.client.SpringCloudApplication;
|
||||
import org.springframework.cloud.netflix.turbine.EnableTurbine;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
|
||||
|
||||
import de.codecentric.boot.admin.config.EnableAdminServer;
|
||||
|
||||
/**
|
||||
* 描述 : 系统入口
|
||||
*
|
||||
* @author wangkang
|
||||
*/
|
||||
@SpringCloudApplication
|
||||
@EnableAdminServer
|
||||
@EnableTurbine
|
||||
public class UdfAdminServerApplication extends BaseApplication {
|
||||
|
||||
/**
|
||||
* 描述 : spring boot的入口,在整个项目中,包括其子项目在内, 只能有一个main方法,否则spring boot启动不起来
|
||||
*
|
||||
* @param args 参数
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(UdfAdminServerApplication.class, args);
|
||||
}
|
||||
|
||||
/**
|
||||
* 描述 : SecurityConfig
|
||||
*
|
||||
* @author Administrator
|
||||
*/
|
||||
@Configuration
|
||||
public static class SecurityConfig extends WebSecurityConfigurerAdapter {
|
||||
@Override
|
||||
protected void configure(HttpSecurity http) throws Exception {
|
||||
// Page with login form is served as /login.html and does a POST on /login
|
||||
http.formLogin().loginPage("/login.html").loginProcessingUrl("/login").permitAll();
|
||||
// The UI does a POST on /logout on logout
|
||||
http.logout().logoutUrl("/logout");
|
||||
// The ui currently doesn't support csrf
|
||||
http.csrf().disable();
|
||||
// Requests for the login page and the static assets are allowed
|
||||
http.authorizeRequests().antMatchers("/login.html", "/**/*.css", "/img/**", "/third-party/**")
|
||||
.permitAll();
|
||||
// ... and any other request needs to be authorized
|
||||
http.authorizeRequests().antMatchers("/**").authenticated();
|
||||
// Enable so that the clients can authenticate via HTTP basic for registering
|
||||
http.httpBasic();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
########################################################
|
||||
###security (must reboot)
|
||||
########################################################
|
||||
security.user.name=admin
|
||||
security.user.password=123456
|
||||
########################################################
|
||||
###eureka.client ( EurekaInstanceConfigBean , EurekaClientConfigBean , EurekaServerConfigBean ) (must reboot)
|
||||
########################################################
|
||||
eureka.instance.preferIpAddress=true
|
||||
eureka.client.serviceUrl.defaultZone=http://admin:123456@127.0.0.1:9001/eureka/
|
||||
########################################################
|
||||
###spring.cloud.config ( ConfigClientProperties )
|
||||
########################################################
|
||||
spring.cloud.config.username=admin
|
||||
spring.cloud.config.password=123456
|
||||
spring.cloud.config.enabled=true
|
||||
spring.cloud.config.profile=${spring.profiles.active}
|
||||
spring.cloud.config.name=${spring.application.name},base,gzip,mail,rabbitmq
|
||||
spring.cloud.config.label=master
|
||||
spring.cloud.config.failFast=true
|
||||
spring.cloud.config.discovery.enabled=true
|
||||
spring.cloud.config.discovery.serviceId=UDF-EUREKA-CONFIG-SERVER
|
||||
########################################################
|
||||
###spring.boot.admin (http://blog.csdn.net/yiyaopeng/article/details/72887134)
|
||||
########################################################
|
||||
spring.boot.admin.routes.endpoints=env,metrics,trace,dump,jolokia,info,configprops,trace,logfile,refresh,flyway,liquibase,heapdump,loggers,auditevents,hystrix.stream,turbine.stream
|
||||
spring.boot.admin.turbine.location=UDF-ADMIN-SERVER
|
||||
spring.boot.admin.turbine.clusters=default
|
||||
########################################################
|
||||
###turbine ( TurbineProperties )
|
||||
########################################################
|
||||
turbine.clusterNameExpression=new String("default")
|
||||
@@ -0,0 +1,39 @@
|
||||
########################################################
|
||||
###INFO ( note : info.build.time is the UTC time )
|
||||
########################################################
|
||||
info.build.group=${project.groupId}
|
||||
info.build.artifact=${project.artifactId}
|
||||
info.build.version=${project.version}
|
||||
info.build.name=${project.name}
|
||||
info.build.time=${project.build.date}
|
||||
info.build.encoding=${project.build.sourceEncoding}
|
||||
info.build.java.source=${java.version}
|
||||
info.build.java.target=${java.version}
|
||||
########################################################
|
||||
###IDENTITY
|
||||
########################################################
|
||||
spring.application.name=${project.name}
|
||||
########################################################
|
||||
###WEB PROPERTIES (ServerProperties)
|
||||
########################################################
|
||||
server.port=${server.port}
|
||||
########################################################
|
||||
###MANAGEMENT (ManagementServerProperties)
|
||||
########################################################
|
||||
management.security.enabled=false
|
||||
########################################################
|
||||
###PROFILES
|
||||
########################################################
|
||||
spring.profiles.active=${profiles.activation}
|
||||
########################################################
|
||||
###org.itkk.application.config (ApplicationConfig) (must reboot)
|
||||
########################################################
|
||||
org.itkk.application.config.encoding=UTF-8
|
||||
org.itkk.application.config.timeZone=Asia/Shanghai
|
||||
org.itkk.application.config.dateFormat=yyyy-MM-dd'T'HH:mm:ss:SSSZ
|
||||
########################################################
|
||||
### shutdown
|
||||
########################################################
|
||||
endpoints.shutdown.enabled=true
|
||||
endpoints.shutdown.sensitive=true
|
||||
management.port=${management.port}
|
||||
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
<include resource="org/springframework/boot/logging/logback/base.xml" />
|
||||
<jmxConfigurator />
|
||||
</configuration>
|
||||
@@ -48,7 +48,7 @@ org.itkk.application.config.threadPool.poolSize=100
|
||||
########################################################
|
||||
###LOGGING (must reboot)
|
||||
########################################################
|
||||
logging.file=d:/develop/${project.groupId}-log/${spring.application.name}_${server.port}_${spring.profiles.active}/base.log
|
||||
logging.file=d:/develop/application-log/${spring.application.name}_${server.port}_${spring.profiles.active}/base.log
|
||||
########################################################
|
||||
###GZIP (ServerProperties) ((must reboot)
|
||||
########################################################
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
base_path="udf-sample-api"
|
||||
base_path="udf-server"
|
||||
|
||||
echo 'shutdown application begin'
|
||||
returnCode=`curl -I -s -X POST "http://127.0.0.1:${management.port}/shutdown"|head -1|cut -d" " -f2`
|
||||
|
||||
Reference in New Issue
Block a user