build.gradle
compile group: 'de.codecentric', name: 'spring-boot-admin-starter-server', version: '1.5.7'
@EnableAdminServer
@Configuration @EnableAutoConfiguration @EnableAdminServer public class SpringBootAdmin { public static void main(String[] args) { SpringApplication.run(SpringBootAdminApplication.class, args); } }
build.gradle
compile group: 'de.codecentric', name: 'spring-boot-admin-starter-client', version: '1.5.7'
application.properties
spring.boot.admin.url=http://localhost:8070 management.security.enabled=false
META-INF/build-info.properties
pom.xml
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>build-info</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
build.gradle
springBoot {
buildInfo()
}
logback-spring.xml
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<include resource="org/springframework/boot/logging/logback/base.xml"/>
<jmxConfigurator/>
</configuration>
@Configuration
@EnableScheduling
public class NotifierConfiguration {
@Autowired
private Notifier delegate;
@Bean
public FilteringNotifier filteringNotifier() { // 1.Add the FilteringNotifier bean using a delegate (e.g. MailNotifier when configured)
return new FilteringNotifier(delegate);
}
@Bean
@Primary
public RemindingNotifier remindingNotifier() { // 2.Add the RemindingNotifier as primary bean using the FilteringNotifier as delegate.
RemindingNotifier notifier = new RemindingNotifier(filteringNotifier());
notifier.setReminderPeriod(TimeUnit.SECONDS.toMillis(10)); // 3.The reminders will be sent every 10 seconds.
return notifier;
}
@Scheduled(fixedRate = 1_000L) // 4.Schedules sending of due reminders every 1 seconds.
public void remind() {
remindingNotifier().sendReminders();
}
}
build.gradle
compile group: 'de.codecentric', name: 'spring-boot-admin-server-ui-login', version: '1.5.7'
SpringBootAdmin
@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(); } }
spring-boot/application.properties
spring.boot.admin.username=user spring.boot.admin.password=pass
Submitting the credentials using SBA Client:
spring.boot.admin:
url: http://localhost:8080
client:
metadata:
user.name: ${security.user.name}
user.password: ${security.user.password}