Search code examples
javaspringspring-bootspring-boot-actuatorspring-boot-admin

How to use spring boot admin of version 2 and spring boot of version 1.5?


I have following dependencies:

dependencies {
    compile('org.springframework.boot:spring-boot-starter')
    compile group: 'de.codecentric', name: 'spring-boot-admin-server-ui', version: '2.1.3'
    compile group: 'de.codecentric', name: 'spring-boot-admin-server', version: '2.1.3'
    testCompile('org.springframework.boot:spring-boot-starter-test')
}

springBootVersion = '1.5.3.RELEASE'

When I try to start my application:

@EnableAdminServer
@SpringBootApplication
public class MonitoringAdminApplication {

    public static void main(String[] args) {
        SpringApplication.run(MonitoringAdminApplication.class, args);
    }

}

I see error:

Exception in thread "main" java.lang.NoClassDefFoundError: org/thymeleaf/spring5/templateresolver/SpringResourceTemplateResolver
    at java.lang.Class.getDeclaredMethods0(Native Method)
    at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
    at java.lang.Class.getDeclaredMethods(Class.java:1975)
    at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:613)
    at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:524)
    at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:510)
    at org.springframework.util.ReflectionUtils.getUniqueDeclaredMethods(ReflectionUtils.java:570)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.getTypeForFactoryMethod(AbstractAutowireCapableBeanFactory.java:697)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineTargetType(AbstractAutowireCapableBeanFactory.java:640)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:609)
    at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1484)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doGetBeanNamesForType(DefaultListableBeanFactory.java:425)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:395)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:515)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:508)
    at org.springframework.context.support.AbstractApplicationContext.getBeansOfType(AbstractApplicationContext.java:1189)
    at org.springframework.boot.SpringApplication.getExitCodeFromMappedException(SpringApplication.java:862)
    at org.springframework.boot.SpringApplication.getExitCodeFromException(SpringApplication.java:848)
    at org.springframework.boot.SpringApplication.handleExitCode(SpringApplication.java:834)
    at org.springframework.boot.SpringApplication.handleRunFailure(SpringApplication.java:788)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:325)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1162)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1151)
    at com.******.MonitoringAdminApplication.main(MonitoringAdminApplication.java:13)
Caused by: java.lang.ClassNotFoundException: org.thymeleaf.spring5.templateresolver.SpringResourceTemplateResolver
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 24 more

I tried to downgrade version of spring-boot-admin-server-ui and spring-boot-admin-server to 1.5.5 and after it application starts successfully.

But I want to use the latest version. I am not able use spring boot 2.

How can I fix it?


Solution

  • You can't and you shouldn't. Spring-boot-admin, just like any other Spring Boot app, is developed on a specific Spring Boot version.

    • spring-boot-admin 1.5.x is based on Spring Boot 1.5.x
    • spring-boot-admin 2.0.x is based on Spring Boot 2.0.x
    • spring-boot-admin 2.1.x is based on Spring Boot 2.1.x

    If you're stuck with Spring Boot 1.5, then you should use spring-boot-admin 1.5.7 (the latest version from the 1.5.x branch).