用于独立弹簧应用的弹簧启动执行器

时间:2017-02-17 09:45:20

标签: spring spring-boot spring-boot-actuator

我正在尝试学习弹簧启动器。我有一个简单的基本应用程序,通过main方法运行。它没有tomcat或任何东西。它只有一个类如下

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");
    }
}

我在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>

我试图查看应用程序运行状况和信息,我在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
尝试使用网址时

http://localhost:8091/info 它永远不会得到解决。

是否无法为独立应用程序配置执行器?

2 个答案:

答案 0 :(得分:1)

您的应用程序还不是Spring Boot App。

必须至少使用func setPlayerRate(player: AVPlayer, rate: Float) { // AVFoundation wants us to do most things on the main queue. DispatchQueue.main.async { if (rate == player.rate) { return } if (rate > 2.0 || rate < -2.0) { let playerItem = player.currentItem player.replaceCurrentItem(with: nil) player.replaceCurrentItem(with: playerItem) player.rate = rate } else { // No problems "out of the box" with rates in the range [-2.0,2.0]. player.rate = rate } } } 将应用转换为一个。

@SpringBootApplication

是一个最简单的例子。

如果没有这个,你的类路径中的spring-boot依赖关系并没有被要求做出神奇的事情来使你的应用程序变得聪明。一体化注释使spring-boot的@SpringBootApplication public class BootadminMsAlphaApplication { public static void main(String[] args) { SpringApplication.run(BootadminMsAlphaApplication.class, args); } } 发挥作用,为应用程序配置了很多好东西,包括Actuators(如果在classpath中)。

答案 1 :(得分:0)

看起来您的应用程序不是Spring Boot应用程序。它需要。

相关问题