数据库配置读取

This commit is contained in:
myh 2023-10-06 23:33:18 +08:00
parent 37988c4ff0
commit 717c7bbc05
2 changed files with 4 additions and 13 deletions

View File

@ -5,10 +5,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication @SpringBootApplication
public class SpringDemoApplication { public class SpringDemoApplication {
public static void main(String[] args) { public static void main(String[] args) {
SpringApplication.run(SpringDemoApplication.class, args); SpringApplication.run(SpringDemoApplication.class, args);
} }
} }

View File

@ -1,21 +1,15 @@
package com.example.springdemo.config; package com.example.springdemo.config;
import lombok.Data; import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@Data @Data
@Component @Component
@ConfigurationProperties(prefix = "business.security") @ConfigurationProperties(prefix = "spring.datasource")
public class DataBaseProperties { public class DataBaseProperties {
private String url;
private String dbUrl; private String username;
private String password;
//@Value("${db.username}")
private String username ;
//@Value("${db.password}")
private String password ;
} }