gpt4 book ai didi

java - Eclipse 无法正确复制上下文

转载 作者:行者123 更新时间:2023-12-01 05:02:08 28 4
gpt4 key购买 nike

Eclipse 版本:(Java EE):3.7 Indigo,32 位
Tomcat版本:6.0
操作系统: Windows 7 64 位 SP1

问题:我在 Eclipse 中创建了一个动态 Web 应用程序 xyz。正确集成 Eclipse 和 Tomcat 后,我​​将 xyz 添加到本地服务器实例,并在 server.xml(在 Eclipse 服务器项目中)中编辑 xyz 的上下文条目以包含 jdbc 资源引用。

server.xml(在 Eclipse 中。下面的用户名、密码、IP 等已更改)

<Context docBase="xyz" path="/xyz" reloadable="true" source="org.eclipse.jst.j2ee.server:xyz">
<Resource auth="Container"
driverClassName="oracle.jdbc.driver.OracleDriver"
factory="org.apache.commons.dbcp.BasicDataSourceFactory"
maxActive="100"
maxIdle="30"
name="jdbc/xyz"
username="123"
password="123"
type="javax.sql.DataSource"
url="jdbc:oracle:thin:@1.1.1.1:sid" />
</Context>

但是,当 Eclipse 发布此 server.xml 文件到热部署文件夹时(在 Windows 中,位于 .metadata ... > tmp0 > conf),Eclipse 完全忽略资源引用。部署的 server.xml 文件如下所示:

<Context
docBase="C:\ws\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\xyz"
path="/xyz"
reloadable="true"
source="org.eclipse.jst.j2ee.server:xyz" />

为什么会发生这种情况? (有解决办法吗?)。换句话说,如何让 Eclipse 部署 server.xml 文件使用我的资源引用?

最佳答案

您应该将数据源条目放在 Context.xml 中而不是Server.xml

不建议使用<Context></context>在版本 6.0 的 server.xml 中从此。

更新:解决Sever.xml不复制的问题

引用此报价Source

You don't need to edit the copy in the temp directory. It will be updated from the master copy (currently in configs) the next time you publish.

Since you know enough about the Tomcat configuration, there's another thing that will help. Under Preferences > Server, select the checkbox that creates resources in the workspace. Then delete the existing Tomcat server and create another one. This will create all the resources inside the workspace instead of in the .metadata directory, so you can edit them alongside other files in your workspace.

关于java - Eclipse 无法正确复制上下文,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13246541/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com