package com.bootdo.demo.service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.EnvironmentAware;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Service;
import com.bootdo.demo.dao.DemoDao;
import com.bootdo.demo.domain.DemoEntity;
@Service
public class DemoPar implements EnvironmentAware{
@Autowired
public void setEnvironment(Environment env) { //env 包含全局的所有的变量
// TODO Auto-generated method stub
s=property;
}
}
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.EnvironmentAware;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Service;
import com.bootdo.demo.dao.DemoDao;
import com.bootdo.demo.domain.DemoEntity;
@Service
public class DemoPar implements EnvironmentAware{
@Autowired
static String s;
static Map map();
static RelaxedPropertyResolver propertyResolver;
public void setEnvironment(Environment env) { //env 包含全局的所有的变量
// TODO Auto-generated method stub
propertyResolver = new RelaxedPropertyResolver(env, "druid."); //获取所有druid. 下面的属性并封装起来
String initialSize = propertyResolver.getProperty("initialSize"); //获取propertyResolver 中 key为 initialSize 的值
String minIdle =propertyResolver.getProperty("minIdle"); //获取propertyResolver 中 key为 minIdle 的值
String maxActive = propertyResolver.getProperty("maxActive"); //获取propertyResolver 中 key为 maxActive 的值
s=property;
}
}