关于persistence.xml问题,急!!!!!!!!!!!!!!!

redlotus_lyn 2009-02-13 05:40:46
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
version="1.0">

<persistence-unit name="szkappPU"
transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<properties>
<property name="hibernate.connection.driver_class"
value="org.postgresql.Driver" />
<property name="hibernate.connection.url"
value="jdbc:postgresql://localhost:5432/szkapp" />
<property name="hibernate.connection.username"
value="postgres" />
<property name="hibernate.connection.password"
value="postgres" />

</properties>
</persistence-unit>

</persistence>

红色连接数据部分,怎么能用properties文件加载。
...全文
164 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
Landor2004 2009-02-14
  • 打赏
  • 举报
回复
jpa支持programmatic configuration,例如:

Map myProperties = new HashMap();
myProperties.put("hibernate.connection.driver_class", "org.postgresql.Driver");
......
EntityManagerFactory emf = Persistence.createEntityManagerFactory("szkappPU", myProperties);
EntityManager em = emf.createEntityManager();
bruni 2009-02-14
  • 打赏
  • 举报
回复
头一回碰到你这种情况
你没有用spring之类的框架么?
好像不用这么复杂吧?

81,090

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧