zoukankan      html  css  js  c++  java
  • 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
                }
            }
        }
    }

    日志:

  • 相关阅读:
    理解SSL、HTTPS原理中的对称加密与非对称加密
    lib下的Jar包在项目打包的时候提示不能找不到
    springboot2.0 最大上传文件大小遇到的错误Failed to bind properties under 'spring.servlet.multipart.max-file-size'
    Executors创建线程池的几种方式以及使用
    JAVA深入研究——Method的Invoke方法(转)
    git merge 与 git rebase的区别
    git rebase
    git fetch , git pull
    nginx搭建(centos7)
    idea过期激活
  • 原文地址:https://www.cnblogs.com/yaoyuan2/p/10394809.html
Copyright © 2011-2022 走看看