而不是我的應用程序中實例化一個PersistenceManagerFactory
這樣的:如何在Spring中將屬性的HashMap傳遞給Autowired bean?
Properties properties = new Properties();
properties.setProperty("javax.jdo.PersistenceManagerFactoryClass",
"org.datanucleus.jdo.JDOPersistenceManagerFactory");
properties.setProperty("javax.jdo.option.ConnectionDriverName","com.mysql.jdbc.Driver");
properties.setProperty("javax.jdo.option.ConnectionURL","jdbc:mysql://localhost/myDB");
properties.setProperty("javax.jdo.option.ConnectionUserName","login");
properties.setProperty("javax.jdo.option.ConnectionPassword","password");
PersistenceManagerFactory pmf = JDOHelper.getPersistenceManagerFactory(properties);
我想在春天這樣的配置它依賴注入:
<bean id="persistenceManagerFactory" class="org.springframework.orm.jdo.LocalPersistenceManagerFactoryBean" lazy-init="true">
<property name="persistenceManagerFactoryName" value="transactions-optional" />
</bean>
但我不知道怎麼打發在application-context.xml
中的Properties
(不使用jdoconfig.xml
)。
是否有可能在application-context.xml
通過所有這些Properties
自動裝配的值?