spring - CloudFoundry MySQL Java configuration -


i have spring mvc app running fine on local tomcat etc. spring 3.1 mvc/hibernate app.

i using (where possible) pure java @configuration app - , trying deploy app cloudfoundry (via sts), struggling mysql db configured (from memory, xml config dont need , spring/cloudfoundry auto-injects required user/password etc, been while since deployed cf).

i have tried both of following configurations:

@bean public basicdatasource datasource() throws propertyvetoexception {     //cloudfoundry config     final cloudenvironment cloudenvironment = new cloudenvironment();         final list<mysqlserviceinfo> mysqlservices = cloudenvironment.getserviceinfos(mysqlserviceinfo.class);         final mysqlserviceinfo serviceinfo = mysqlservices.get(0);      basicdatasource bean = new basicdatasource();     bean.setdriverclassname("com.mysql.jdbc.driver");     bean.seturl(serviceinfo.geturl());     bean.setusername(serviceinfo.getusername());     bean.setpassword(serviceinfo.getpassword());     return bean; } 

the above failed on out of bounds on .get(0) line of mysqlservices. based on answer suggested here.

i tried leaving datasource runs on local see if properties injected, no luck there either. (the below tried values per spring sample code here, , using property placeholders db.connection props file)

@bean public basicdatasource datasource() throws propertyvetoexception {     basicdatasource bean = new basicdatasource();     bean.setdriverclassname("com.mysql.jdbc.driver");     bean.seturl("");     bean.setusername("spring");     bean.setpassword("spring");     return bean; } 

edit

i have used getserviceinfo(string, class) method passing in name of mysql service have created , bound application, npes similar getserviceinfos(..) approach

ok, stupid mistake - when deployed app via sts had selected java web app rather "spring" type. not sure why make cloudenvironment properties not available (i under impression approach common method inject details in non-spring apps) - re-deploying server spring app resolved probs!


Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -