Friday, September 13, 2019

Spring Boot Admin Server and Client

Create a spring boot application and following dependencise in pom.xml
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.4.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<dependencies>
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-server</artifactId>
<version>1.5.1</version>
</dependency>
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-server-ui</artifactId>
<version>1.5.1</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
Add following @EnableAdminServer in our main Server class
@SpringBootApplication
@EnableAdminServer
public class SiddhuSpringBootAdminServerApplication {
public static void main(String[] args) {
SpringApplication.run(SiddhuSpringBootAdminServerApplication.class, args);
}
}
Add following lines in your admin configuration properties
server.port = 9090
spring.application.name = adminserver
Compile the server and run the application
java -jar C:\Latest_workspace-sts-3.9.6.RELEASE\siddhu-spring-boot-admin-server\target\siddhu-spring-boot-admin-server-0.0.1-SNAPSHOT.jar

Image1Image2Image3Image4
And hit url
http://localhost:9090/#/
Image5
Now lets create the spring boot application admin client. Create an spring boot application and following dependencise in pom.xml
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.4.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<dependencies>
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-client</artifactId>
<version>1.5.1</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
@SpringBootApplication
public class SiddhuSpringBootAdminClientApplication {
public static void main(String[] args) {
SpringApplication.run(SiddhuSpringBootAdminClientApplication.class, args);
}
}
Add following lines in your admin configuration properties
spring.boot.admin.url=http://localhost:9090/
Image6Image7Image8Image9

java -Dserver.port=8888 -jar C:\Latest_workspace-sts-3.9.6.RELEASE\siddhu-spring-boot-admin-client\target\siddhu-spring-boot-admin-client-0.0.1-SNAPSHOT.jar
Compile the server and run the application and hit url
http://localhost:9090/#/
Image10

No comments: