java - Spring3 Security JDBC how to load connect info -


I am working on the sample 2 weeks now and I was working on this, but datosorcing was done on applicationcontext, but now I am unable to load the connection information from my file. I have coded it hard and it works, but I would like to load it with a file. Someone can tell me what I'm missing from my AppicationContext to work .. Thank you

ApplicationContext-Security.xml

  & lt; Beans: Bean id = "data source" class = "org.springframework.jdbc.datasource.DriverManagerDataSource" & gt; & Lt; Beans: property name = "driverClassName" value = "$ {database.driver}" /> & Lt; Beans: property name = "url" value = "$ {database.url}" /> & Lt; Beans: property name = "user name" value = "$ {database.user}" /> & Lt; Beans: property name = "password" value = "$ {database.password}" /> & Lt; / Beans: bean   

& gt;

has been changed to the following and it works:

  & lt; Beans: Bean id = "datasource" class = "org.springframework.jdbc.datasource.DriverManagerDataSource" & gt; & Lt; Beans: Properties name = "driverClassName" value = "com.mysql.jdbc.Driver" /> & Lt; Beans: Properties name = "url" value = "jdbc: mysql: //127.0.0.1/db_mytest" /> & Lt; Beans: Property Name = "User Name" Value = "Basic" /> & Lt; Beans: Properties name = "password" value = "" /> & Lt; / Bean: beans & gt;   

But I should not code this hard. Please help me.

Maybe you can try to specify the dataset settings in the properties file and then the properties You can include more information in this blog using the PropertyPlaceholderConfigurer file

Comments