I am trying to use Springboot admin app and am unable to get the basics working.
I started with the simplest springboot web app (using starter-web and starter-test) and added the springboot-admin-server and springboot-admin-server-ui to the list of dependencies.
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!-- Added Dependency for Admin Server and its UI -->
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-server</artifactId>
<version>1.4.5</version>
</dependency>
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-server-ui</artifactId>
<version>1.4.5</version>
</dependency>
</dependencies>
Trying to execute mvn clean package throws up errors. The root cause is shown below.
Caused by: java.lang.ClassNotFoundException: org.springframework.boot.context.embedded.ServletRegistrationBean
at java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[na:1.8.0_112]
at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_112]
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) ~[na:1.8.0_112]
at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_112]
... 51 common frames omitted
The springboot app has absolutely the barebones implementation (the addition of the EnableAdminServer annotation as shown below)
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import de.codecentric.boot.admin.config.EnableAdminServer;
@SpringBootApplication
@EnableAdminServer
public class WorkingExampleSpringBootAdminApplication {
public static void main(String[] args) {
SpringApplication.run(WorkingExampleSpringBootAdminApplication.class, args);
}
}
I am guessing that this error occurs because this class (org.springframework.boot.context.embedded.ServletRegistrationBean) has been replaced with org.springframework.boot.web.servlet.ServletRegistrationBean (in 1.5.x)and this is likely used by the spring-boot-admin-server components.
I got around this issue by switching to an earlier version of Springboot (say 1.4.4). Is that the right thing to do? Or am I making any mistakes in my configuration?
Using the version 1.4.6 of spring-boot-admin-server and spring-boot-admin-server-ui instead of 1.4.5 fixes the issue.