JNDI和Spring配置-jee:lookup
我想使用JNDI将我的类发布为资源之一。在Tomcat的context.xml中JNDI和Spring配置-jee:lookup,spring,tomcat,jndi,Spring,Tomcat,Jndi,我想使用JNDI将我的类发布为资源之一。在Tomcat的context.xml中 <Resource name="jdbc/dialect" type="pl.meble.taboret.utils.SQLiteDialect" auth="Container"/> 我在无参数构造函数的末尾添加了打印,似乎对象已经构造好了,所以我不知道为什么它会抱怨init方法调用失败我非常确定您需要使用驱动程序而不是方言(这是我为MySQL设置的,只需为特定的sql impl
<Resource
name="jdbc/dialect"
type="pl.meble.taboret.utils.SQLiteDialect"
auth="Container"/>
我在无参数构造函数的末尾添加了打印,似乎对象已经构造好了,所以我不知道为什么它会抱怨init方法调用失败我非常确定您需要使用驱动程序而不是方言(这是我为MySQL设置的,只需为特定的sql impl更改驱动程序)
然后
<resource-ref>
<description>The JNDI Database resource</description>
<res-ref-name>jdbc/myname</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Application</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
JNDI数据库资源
jdbc/myname
javax.sql.DataSource
应用
可分享
我想您应该将hibernate.dialogue设置为pl.meble.taboret.utils.sqlitedialogue,而不是您正在执行的操作。尝试以下操作:
<Resource
name="jdbc/dialect"
type="java.lang.String"
value="pl.meble.taboret.utils.SQLiteDialect"
auth="Container"/>
<resource-ref>
<description>sqlite dialect</description>
<res-ref-name>jdbc/dialect</res-ref-name>
<res-type>java.lang.String</res-type>
<res-auth>Container</res-auth>
</resource-ref>
sqlite方言
jdbc/方言
java.lang.String
容器
然后执行JNDI查找,将值转换为字符串并将其提供给Class.forName()方法。我知道您的建议,但我想将hibernate方言外部化,我已经正确配置了数据源。
<Resource name="jdbc/myname" auth="Container" type="javax.sql.DataSource"
maxActive="100" maxIdle="30" maxWait="10000"
username="user" password="pass" driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://url/db"/>
<resource-ref>
<description>The JNDI Database resource</description>
<res-ref-name>jdbc/myname</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Application</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
<Resource
name="jdbc/dialect"
type="java.lang.String"
value="pl.meble.taboret.utils.SQLiteDialect"
auth="Container"/>
<resource-ref>
<description>sqlite dialect</description>
<res-ref-name>jdbc/dialect</res-ref-name>
<res-type>java.lang.String</res-type>
<res-auth>Container</res-auth>
</resource-ref>