【发布时间】:2018-05-15 17:16:08
【问题描述】:
我正在配置一个 Spring Boot 应用程序。所以我创建了一个这样的属性 bean 类:
import javax.validation.constraints.NotNull;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
@Configuration
@EnableConfigurationProperties
@PropertySource("classpath:/application.properties")
public class APPStaticProperties {
@NotNull
@Value("${dblog.system.name}")
String db_logsystem_name;
/**
* @return the db_logsystem_name
*/
public String getDb_logsystem_name() {
return db_logsystem_name;
}
/**
* @param db_logsystem_name the db_logsystem_name to set
*/
public void setDb_logsystem_name(String db_logsystem_name) {
this.db_logsystem_name = db_logsystem_name;
}
}
我正在控制器类中创建一个对象:
@Autowired
APPStaticProperties appStaticProperties;
但我想知道如何传递 this 对象以在其他项目中使用?因为我的代码流从控制器到 JSP,然后到另一个项目中的类。我需要该类中可用的对象。老实说,在许多其他项目中也是如此!我无法弄清楚该怎么做。也没有太多的例子可供参考。
【问题讨论】:
标签: java spring spring-boot properties