23333333333333333333

本文详细介绍了如何在SpringBoot项目中使用@Configuration注解创建配置类,以及@Component和@Autowired注解的应用,展示了如何定义Bean和调用Pojo类中的方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

package com.example.demo.configuration;

import com.example.demo.pojo.Role;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class Myconfiguration {
    @Bean
    public String msg(){
        return "this";
    }

    @Bean
    public Role myRole(){
        return new Role();
    }
}
package com.example.demo.pojo;

import org.springframework.stereotype.Component;

@Component
public class Role {
    private String name;
    private String description;


    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }


    @Override
    public String toString() {
        return "Role{" +
                "name='" + name + '\'' +
                ", description='" + description + '\'' +
                '}';
    }
}
package com.example.demo.controller;

import com.example.demo.pojo.Role;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class MyConfigurationController {
    @Autowired
    private String msg;

    @Autowired
    private Role role;

    @GetMapping("/test")
    public String test(){
        return msg;
    }
    @GetMapping("/role")
    public String getRole(){
        return role.toString();
    }
}

#include "headfile.h" #define PWM_1 PWMA_CH4P_P66 #define PWM_2 PWMA_CH2P_P62 #define PWM_3 PWMA_CH3P_P64 #define PWM_4 PWMA_CH1P_P60 #define DIR_1 P64 #define DIR_2 P60 #define SPEEDL_PLUSE CTIM0_P34 #define SPEEDR_PLUSE CTIM3_P04 #define SPEEDL_DIR P35 #define SPEEDR_DIR P53 #define BEEP P77 //定义按键引脚 #define KEY1_PIN P70 #define KEY2_PIN P72 #define KEY3_PIN P71 #define KEY4_PIN P73 //定义拨码开关引脚 #define SW1_PIN P75 #define SW2_PIN P76 int sanjibuflag=0,qinphuan=0,inphuan=0,qinP=0,P_ru=0; float s_ruku_on=0,s_pluse_ruku=0,daojian=0,rukut=1,movestop=0,luoma=0; int shangpo=0,qshangpo=0,shangpozhi=0,sanchaon=0,pogo=0,sanchapingdao=0,ox=0,oU=0,ruku=0,qsanchaon=0,sanchaonzhi=0,rukup=1,jiwan=0,inP=0,s_P_on=0,s_pluse_P=0; float s_pluse_sancha=0,hpp=1,s_way1=0,s_way2=0,s_way3=0,s_way=0; int s_sancha_on=0,flag_dao_in=0; int maxpwm=3000,pxom=0; int opp=0; float MIN01=0; int daop=0; int tdao=0; int ea_left=0,eb_left=0,ec_left=0; int ea_right=0,eb_right=0,ec_right=0; float speedL_P=3,speedL_I=2,speedL_D=1; ///////////////////////////////////////////////////// float speedR_P=3,speedR_I=2,speedR_D=1; int pwm_L=0,pwm_R=0; int abc=0; int Left[10],Left_M[10],Right[10],Right_M[10],Mid[10],EX[10],FX[10],Mid2[10]; uint32 adc[8]; uint8 i=0,j=0; int AD_MinValue[8] = {0,0,0,0,0,0,0,0};//四路电感最小值 abcdMef M2 int AD_MaxValue[8] = {370,350,350,370,820,550,550,780};//四路电感最大值,1,2,3,4 float data1=0,data2=0,data3=0,data4=0,data5=0,data6=0,data7=0,data8=0; int max1=10,max2=10,max3=10,max4=10,max5=10,max6=10,max7=10,max8=10; int angle=705,Q=0,qangle=0,anglepuls=0; float a=0,b=0,c=0,d=0,M=0,e=0,f=0,M2=0,cha=0,weizhi=0,qiancha=0; float qa=0,qb=0,qc=0,qd=0,qM=0,qe=0,qf=0,qM2=0; float cha1=1,cha2=1,cha3=1,he1=1,he2=1,he3=1; float x=0,y=0,g=0,U=0,oy=0,ocha=0; float gx=0.8,gy=0.1,gg=0.1; //23333333333333333333 float disP=5,disD=1; //比例设置 float k=50,kb=0; //2333333333333333333 kb=0 角可能不够不通过 kb过大会向内过偏 kb=0.6直道震荡 但弯道优秀 int16 stopmada=1; int16 templ_pluse = 0; int16 tempr_pluse = 0; int dao=0,daolast=0,t=0,indao=0,outdao=0,zhidao=0,W=0,wandao=1,sancha=0,diuxian=0,daof=0; int qzhidao=0,qwandao=0,qsancha=0,sanchazhi=0; int set_duty=100,set_dutyl=100,set_dutyr=100; int bt=0,Sbing=0,bti=0; int16 time=0; int16 time1=0,time2=0,time3=0,time4=0,time5=0; int sw1_status=1; int sw2_status=1; int key1_status = 1; int key2_status = 1; int key3_status = 1; int key4_status = 1; //上一次开关状态变量 int key1_last_status; int key2_last_status; int key3_last_status; int key4_last_status; int sw1_last_status; int sw2_last_status; int oncestart=1,onceend=1,tu=0; float t2=0; int t1=0; //开关标志位 int key1_flag; int key2_flag; int key3_flag; int key4_flag; int sw1_flag; int sw2_flag; int sure=0;
03-15
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值