【问题标题】:Spring3 Security JDBC how to load connect infoSpring3 Security JDBC如何加载连接信息
【发布时间】:2011-03-29 00:11:50
【问题描述】:

Spring3 Security JDBC如何加载连接信息

我已经在这个 Spring3 Security JDBC 示例上工作了 2 周,我得到了它的工作,但是将数据源添加到 ApplicationContext 但现在我无法让它从我的文件中加载连接通知。我对其进行了硬编码并且它可以工作,但我希望它从文件中加载。有人可以告诉我我的 AppicationContext 中缺少什么以使其正常工作..谢谢

ApplicationContext-Security.xml

<beans:bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<beans:property name="driverClassName" 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

>

更改为以下,它的工作原理:

<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>

但我不想硬编码。请帮帮我。

【问题讨论】:

    标签: java spring jdbc spring-security


    【解决方案1】:

    也许您可以尝试将数据源设置指定到属性文件中,然后使用 PropertyPlaceholderConfigurer 包含属性文件,您可以在此博客http://www.summa-tech.com/blog/2009/04/20/6-tips-for-managing-property-files-with-spring/ 中找到更多信息

    【讨论】:

      猜你喜欢
      • 2012-02-19
      • 2011-07-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-07-24
      • 2017-09-12
      • 2021-11-20
      • 1970-01-01
      相关资源
      最近更新 更多