1

I am trying to learn spring boot actuator. I have a simple basic application which runs via main method. It has not tomcat or anything. It has just one class as below

public class StartUp {

    public static void main(String... args) throws InterruptedException {
        ConfigurableApplicationContext ctx = SpringApplication.run(StartUp.class,
                args);

        StartUp mainObj = ctx.getBean(StartUp.class);

        mainObj.init();

        System.out.println("Application exited");
    }

    public void init() throws InterruptedException {
        System.out.println("inside init method");
        Thread.sleep(10 * 60 * 1000);
        System.out.println("outside init method");
    }
}

I have configured spring actuator as below in pom:

<parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.3.3.RELEASE</version>
    </parent>

    <dependencies>
        <!-- [3] -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

I was trying to view the applications health and info, i have configured the below in application.properties

management.port=8091
management.address=127.0.0.1
management.security.enabled=false
endpoints.shutdown.enabled=true
info.app.name=Startup Dashboard
info.app.version=2.0-ALPHA
logging.file=dashboard.log

while trying the url : http://localhost:8091/info it never gets resolved.

Is it not possible to configure actuator for standalone applications ?

Ambuj Jauhari
  • 1,187
  • 4
  • 26
  • 46
  • I think you are experimenting with Spring-boot, please use this approach to start with in this below link. http://stackoverflow.com/questions/39245732/java-lang-noclassdeffounderror-org-springframework-core-env-configurableenviron/39246493#39246493 – Praveen Kumar K S Feb 17 '17 at 17:01

2 Answers2

1

Your application is not a Spring Boot App yet.

One has to use the @SpringBootApplication at the minimum to convert an app into one.

@SpringBootApplication
public class BootadminMsAlphaApplication {

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

is one such simplest example.

Without this, the spring-boot dependency in your classpath have not been asked to do its magical things to make your application smart. The all-in-one annotation brings spring-boot's auto-configuration into play, that configures a lot of good stuff for the app, including Actuators (if in classpath).

Ashwin Gupta
  • 920
  • 1
  • 11
  • 17
0

It looks like your application isn't a Spring Boot application. It needs to be.

PaulNUK
  • 4,774
  • 2
  • 30
  • 58