开发者

Spring3 Security JDBC how to load connect info

Spring3 Security JDBC how to load connect info

I been working on this sample of Spring3 Security JDBC for 2 weeks now and I got it working but adding the dataSource been to the ApplicationContext but now I cant get it loading the connection inform from my file. I hard coded it and it works but I would like it to load from a file. can someone please tell me what I am missing from my AppicationContext to get it to work.. thanks

ApplicationContext-Security.xml

<beans:bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<beans:property name="driverClassNa开发者_运维问答me" value="${database.driver}" />
<beans:property name="url" value="${database.url}" />
<beans:property name="username" value="${database.user}" />
<beans:property name="password" value="${database.password}" />
</beans:bean

>

Changed to following and it works:

<beans:bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<beans:property name="driverClassName" value="com.mysql.jdbc.Driver" />
<beans:property name="url" value="jdbc:mysql://127.0.0.1/db_mytest" />
<beans:property name="username" value="root" />
<beans:property name="password" value="" />
</beans:bean>

but I dont want to hard code it. please help me.


Maybe you can try specifying the datasource settings into a properties file and then include the properties file using the PropertyPlaceholderConfigurer, you can find more info in this blog http://www.summa-tech.com/blog/2009/04/20/6-tips-for-managing-property-files-with-spring/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜