springboot启动初始化实例,后面进行使用

Posted 健康平安的活着

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了springboot启动初始化实例,后面进行使用相关的知识,希望对你有一定的参考价值。

一 工程结构

二 代码

2.1 javabean

package com.ljf.spring.boot.demo.model;

/**
 * @ClassName: DeviceRunStateVo
 * @Description: TODO
 * @Author: liujianfu
 * @Date: 2021/04/02 11:37:31 
 * @Version: V1.0
 **/
public class DeviceRunStateVo {
    private  String deviceName;//设备名称  电机,皮带
    private  int deviceTotal;//设备总数
    private  int runTotal;//运行设备数
    private  int stopTotal;//停止设备数
    private  int brokenTotal;//故障设备数
    private  String currentTotalTime;//统计时间
    public String getDeviceName() {
        return deviceName;
    }

    public void setDeviceName(String deviceName) {
        this.deviceName = deviceName;
    }

    public int getDeviceTotal() {
        return deviceTotal;
    }

    public void setDeviceTotal(int deviceTotal) {
        this.deviceTotal = deviceTotal;
    }

    public int getRunTotal() {
        return runTotal;
    }

    public void setRunTotal(int runTotal) {
        this.runTotal = runTotal;
    }

    public int getStopTotal() {
        return stopTotal;
    }

    public void setStopTotal(int stopTotal) {
        this.stopTotal = stopTotal;
    }

    public int getBrokenTotal() {
        return brokenTotal;
    }

    public void setBrokenTotal(int brokenTotal) {
        this.brokenTotal = brokenTotal;
    }

    public String getCurrentTotalTime() {
        return currentTotalTime;
    }

    public void setCurrentTotalTime(String currentTotalTime) {
        this.currentTotalTime = currentTotalTime;
    }

    public DeviceRunStateVo(String deviceName, int deviceTotal, int runTotal, int stopTotal, int brokenTotal, String currentTotalTime) {
        this.deviceName = deviceName;
        this.deviceTotal = deviceTotal;
        this.runTotal = runTotal;
        this.stopTotal = stopTotal;
        this.brokenTotal = brokenTotal;
        this.currentTotalTime = currentTotalTime;
    }

    @Override
    public String toString() {
        return "DeviceRunStateVo{" +
                "deviceName='" + deviceName + '\\'' +
                ", deviceTotal=" + deviceTotal +
                ", runTotal=" + runTotal +
                ", stopTotal=" + stopTotal +
                ", brokenTotal=" + brokenTotal +
                ", currentTotalTime='" + currentTotalTime + '\\'' +
                '}';
    }
}

2.2 config

package com.ljf.spring.boot.demo.config;

import com.ljf.spring.boot.demo.model.DeviceRunStateVo;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * @ClassName: TestConfig
 * @Description: TODO
 * @Author: liujianfu
 * @Date: 2021/06/03 06:03:41 
 * @Version: V1.0
 **/
@Component
public class TestConfig {
    @Bean
    public DeviceRunStateVo initBean(){
        DeviceRunStateVo v=new DeviceRunStateVo("皮带",10,6,5,4,"2018-09-02");

       return v;
    }
}

2.3 使用

2.4 调用

以上是关于springboot启动初始化实例,后面进行使用的主要内容,如果未能解决你的问题,请参考以下文章

Springboot 启动加载机制

springboot启动过程-初始化

SpringBoot:Spring容器的启动过程

SpringBoot之启动初始化CommandLineRunner

SpringBoot启动分析

springboot启动流程 简单流程来了