I'm trying to connect with Openshift MYSQL database using JPA and spring data but getting null value for host and port value (ie [jdbc:mysql://null:null/jbosstest1]) . below is code I'm using . In local,when I set environment varible mannually using Run >> Run Configuation.. command in eclipse then my code is working fine but it is not working in Open shift cloud .
@Value("#{systemProperties['OPENSHIFT_MYSQL_DB_HOST']}")
String host;
@Value("#{systemProperties['OPENSHIFT_MYSQL_DB_PORT']}")
String port;
@Bean
public DataSource dataSource() {
DriverManagerDataSource dataSource = new DriverManagerDataSource();
dataSource.setUrl(String.format(url,host,port));
dataSource.setDriverClassName(driverClass);
dataSource.setUsername(username);
dataSource.setPassword(password);
return dataSource;
}
never mind . i'm able to resolve it using below code but not sure why SpEL was not working . thanks much !!
@Value("${OPENSHIFT_MYSQL_DB_HOST}")
String host;
@Value("${OPENSHIFT_MYSQL_DB_PORT}")
String port;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.