码迷,mamicode.com
首页 > 其他好文 > 详细

sofa-boot(1)helloworld项目

时间:2019-02-18 12:54:13      阅读:783      评论:0      收藏:0      [点我收藏+]

标签:status   dap   uil   ssh   doc   stat   www   .so   com   

本示例参考:https://www.sofastack.tech/sofa-boot/docs/QuickStart

示例采用sofa-boot 3.1.1版本。

如下步骤:

1、进入https://start.spring.io/,生成web项目

技术图片

 

 

 一定要勾选下边的web依赖,否则无法启动,因为没有导入tomcat。而sofaboot2.3.1版本不存在这个问题。

 

生成例子程序:

技术图片

2、pom.xml

将pom中的

<parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.3.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

替换为

<parent>
        <groupId>com.alipay.sofa</groupId>
        <artifactId>sofaboot-dependencies</artifactId>
        <version>3.1.1</version>
    </parent>

 

接着导入健康检查依赖

<!-- import SOFABoot Dependency healthcheck and infra -->
        <dependency>
            <groupId>com.alipay.sofa</groupId>
            <artifactId>healthcheck-sofa-boot-starter</artifactId>
        </dependency>

3、application.properties

# Application Name
spring.application.name=SOFABoot Demo
# logging path
logging.path=./logs

4、启动SofabootHelloworldApplication.java

...
Tomcat started on port(s): 8080 (http) with context path ‘‘
...

5、查看

查看version

浏览器输入:http://localhost:8080/actuator/versions

[
    {
        "GroupId": "com.alipay.sofa",
        "Doc-Url": "http://www.sofastack.tech/sofa-boot/docs/Home",
        "ArtifactId": "healthcheck-sofa-boot-starter",
        "Commit-Time": "2018-12-29T16:53:31+0800",
        "Commit-Id": "fffd3b47c629cc02b944b11d8fe68684afdb7b9f",
        "Version": "3.1.1",
        "Build-Time": "2019-02-18T09:53:30+0800"
    },
    {
        "GroupId": "com.alipay.sofa",
        "Doc-Url": "http://www.sofastack.tech/sofa-boot/docs/Home",
        "ArtifactId": "infra-sofa-boot-starter",
        "Commit-Time": "2018-12-29T16:53:31+0800",
        "Commit-Id": "fffd3b47c629cc02b944b11d8fe68684afdb7b9f",
        "Version": "3.1.1",
        "Build-Time": "2019-02-18T09:52:12+0800"
    }
]

浏览器输入:http://localhost:8080/actuator/readiness

{
    "status": "UP",
    "details": {
        "SOFABootReadinessHealthCheckInfo": {
            "status": "UP"
        },
        "diskSpace": {
            "status": "UP",
            "details": {
                "total": 78650093568,
                "free": 6799233024,
                "threshold": 10485760
            }
        }
    }
}

日志:

技术图片

 

sofa-boot(1)helloworld项目

标签:status   dap   uil   ssh   doc   stat   www   .so   com   

原文地址:https://www.cnblogs.com/yaoyuan2/p/10394809.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!