我一直在學習如何通過this網站設置Tomcat的連接池。所以我創建了一個context.xml文件並將其放在META-INF目錄中。這就是我現在所擁有的。Tomcat連接池 - 出廠設置
<?xml version="1.0" encoding="UTF-8"?>
<Context>
<Resource name="jdbc/gmustudent" auth="Container"
type="javax.sql.DataSource" driverClassName="com.mysql.jdbc.Driver"
username="root" password="root"
url="jdbc:mysql://localhost:3306/official"
maxActive="100" maxIdle="10" minIdle="5" initialSize="5" maxWait="10000" />
</Context>
但是我想指定工廠的類名。但每次添加此屬性
factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
我在控制檯中遇到了一大堆錯誤。這裏有一些沒有特別的順序。
WARNING: Failed to register in JMX: javax.naming.NamingException: com.mysql.jdbc.Driver
WARNING: Unexpected exception resolving reference java.sql.SQLException: com.mysql.jdbc.Driver
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:gmustudent' did not find a matching property.
因此,當我沒有指定工廠時,網站工作得很好。但是當我做錯誤拋出並沒有任何工作。我做了一些堆棧溢出的研究,發現this後。因此,我將我的tomcat版本從7.0.11更改爲最新版本,但仍然出現錯誤。所以後來我想也許這是在我的server.xml文件中與我的工廠發生了某種衝突,但我幾乎沒有經歷過這樣的調用。但這裏是我的server.xml文件中的資源
<Resource auth="Container" description="User database that can be updated and saved" factory="org.apache.catalina.users.MemoryUserDatabaseFactory" name="UserDatabase" pathname="conf/tomcat-users.xml" type="org.apache.catalina.UserDatabase"/>
那麼這是否與我的context.xml文件中的工廠發生衝突?或者我完全錯了嗎?在一個堅果殼中,我想知道如何在我的context.xml文件中指定一個工廠,而不會發生巨大的錯誤。謝謝你的閱讀。