Browse Source

增加配置文件读取

tags/v1.0.0^2
林万龙 4 years ago
parent
commit
4e7b6e5f34
2 changed files with 29 additions and 0 deletions
  1. +19
    -0
      src/main/java/com/telpo/dipperposition/co/RzlAccount.java
  2. +10
    -0
      src/main/java/com/telpo/dipperposition/config/PositionConfig.java

+ 19
- 0
src/main/java/com/telpo/dipperposition/co/RzlAccount.java View File

@@ -0,0 +1,19 @@
package com.telpo.dipperposition.co;

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

/**
* @program: RzlAccount
* @description: 融智联账号配置
* @author: king
* @create: 2021-01-12 14:02
**/
@Getter
@Setter
@ToString
public class RzlAccount {

private String hello;
}

+ 10
- 0
src/main/java/com/telpo/dipperposition/config/PositionConfig.java View File

@@ -3,12 +3,14 @@ package com.telpo.dipperposition.config;
import com.alibaba.nacos.api.NacosFactory; import com.alibaba.nacos.api.NacosFactory;
import com.alibaba.nacos.api.PropertyKeyConst; import com.alibaba.nacos.api.PropertyKeyConst;
import com.alibaba.nacos.api.config.ConfigService; import com.alibaba.nacos.api.config.ConfigService;
import com.telpo.dipperposition.co.RzlAccount;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import lombok.ToString; import lombok.ToString;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Scope;


import java.util.Properties; import java.util.Properties;


@@ -28,4 +30,12 @@ public class PositionConfig {
@Value("${hello}") @Value("${hello}")
private String hello; private String hello;


@Scope("prototype")
public RzlAccount getRzlAccount() {

RzlAccount rzlAccount = new RzlAccount();
rzlAccount.setHello(hello);
return rzlAccount;
}

} }

Loading…
Cancel
Save