我全局设置了CATALINA_HOME
属性(在.profile
中)。
BJs-Mac-Pro:server bjpeterdelacruz$ echo $CATALINA_HOME
/Users/bjpeterdelacruz/apache-tomcat-8.0.30
在persistence.xml
文件中,我有以下配置:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" 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_2_0.xsd">
<persistence-unit name="jpa-test" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<class>com.bpd.rest.Department</class>
<properties>
<property name="javax.persistence.jdbc.driver" value="org.sqlite.JDBC" />
<property name="javax.persistence.jdbc.url" value="jdbc:sqlite:/${catalina.home}/webapps/server/WEB-INF/classes/hr.db" />
<property name="eclipselink.ddl-generation" value="drop-and-create-tables" />
<property name="eclipselink.ddl-generation.output-mode" value="database" />
</properties>
</persistence-unit>
</persistence>
但是,当我转到URL时,我收到以下异常:
Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.6.2.v20151217-774c696): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: path to '/${catalina.home}/webapps/server/WEB-INF/classes/hr.db': '/${catalina.home}' does not exist
Error Code: 0
如果我硬编码hr.db
文件的路径,一切都很好,但我不想硬编码。
catalina.home
?答案 0 :(得分:0)
您需要删除斜杠,因此网址如下所示:
jdbc:sqlite:${catalina.home}/webapps/server/WEB-INF/classes/hr.db
另见本讨论: