且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

找不到TomEE部署失败的数据源

更新时间:2023-11-18 15:06:52

您可以使用WEB-INF/resources.xml定义一个或多个数据源,也可以使用<tomee-home>/conf文件夹中的tomee.xml文件,如对应部分:

You can either you use WEB-INF/resources.xml to define one or more datasources or the tomee.xml file inside the <tomee-home>/conf folder, as noted in the corresponding section of the TomEE project documentation:

可以通过XML在/conf/tomee.xml文件或WEB-INF/resources.xml文件中声明

A DataSource can be declared via xml in the /conf/tomee.xml file or in a WEB-INF/resources.xml file

但是,resources.xml的语法与容器范围的定义稍有不同.对于与您的网络应用程序捆绑在一起的resources.xml,其格式应如下所示:

However, the syntax for resources.xmlis slightly different from the container-wide definition. For a resources.xml bundled with your web-application it should be formulated as follows:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <Resource id="mysql_ds" type="javax.sql.DataSource">
        JdbcDriver  = com.mysql.jdbc.Driver
        JdbcUrl     = jdbc:mysql://IP:3306/db?serverTimezone=UTC&amp;autoReconnect=true
        UserName    = user
        Password    = password
        JtaManaged  = true
    </Resource>
</resources>

请注意,标签<resources>与问题中给出的<tomee>不同.这应该适用于默认的TomEE环境.另请参阅:rmannibucau发表的评论.

Note well, that the tag <resources> is different from <tomee> given in your question. This should work for a default TomEE environment. See also: comment by rmannibucau.

希望,会有所帮助.