sofa-boot(1)helloworld项目

本示例参考: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
            }
        }
    }
}

日志:

 

转载于:https://www.cnblogs.com/yaoyuan2/p/10394809.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值