Java Eclipse:元素类型;上下文“;必须申报
我正在eclipse上使用“context.xml”与JDBC建立连接池。 它继续说 -必须声明元素类型“资源”。 -必须声明元素类型“Context”。 -必须声明元素类型“WatchedResource” 不过,昨天同样的代码工作得很好。 我刚在学校的电脑上导入了这个项目。 所有其他未使用连接池的文件仍能正常运行。 我使用Tomcat 9.0版 我复制了昨天键入的代码,并将其保存为文本文件。 我删除了“context.xml”文件,然后重新创建。 它仍然不起作用。 我在google和stack Over Flow上搜索,看看是否有人有同样的问题,不幸的是,我找不到任何答案 有人能帮我吗 这是我键入的xml代码Java Eclipse:元素类型;上下文“;必须申报,java,xml,eclipse,tomcat,context.xml,Java,Xml,Eclipse,Tomcat,Context.xml,我正在eclipse上使用“context.xml”与JDBC建立连接池。 它继续说 -必须声明元素类型“资源”。 -必须声明元素类型“Context”。 -必须声明元素类型“WatchedResource” 不过,昨天同样的代码工作得很好。 我刚在学校的电脑上导入了这个项目。 所有其他未使用连接池的文件仍能正常运行。 我使用Tomcat 9.0版 我复制了昨天键入的代码,并将其保存为文本文件。 我删除了“context.xml”文件,然后重新创建。 它仍然不起作用。 我在google和stac
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE context>
<Context path="/" docBase="Webprj" reloadable="true">
<WatchedResource>WEB-INF/web.xml</WatchedResource>
<Resource
name="jdbc/Oracle"
auth="Container"
type="javax.sql.DataSource"
driverClassName="oracle.jdbc.driver.OracleDriver"
url="jdbc:oracle:thin:@127.0.0.1:1521:xe"
username="sijeune" password="oracle"
maxActive="20" maxIdle="10" maxWait="-1"/>
</Context>
WEB-INF/WEB.xml
我的xml文件的根是
'C:\Users\1027\Java\GroupStudy\Webprj\WebContent\META-INF\context.xml'
提前谢谢 我不知道为什么要在项目中单独创建
context.xml
Tomcatconf
目录中已经有一个context.xml
文件。只需将数据源添加到context.xml
发件人:
只需在其中添加数据源
我不知道为什么要在项目中单独创建
context.xml
Tomcatconf
目录中已经有一个context.xml
文件。只需将数据源添加到context.xml
发件人:
只需在其中添加数据源
你好谢谢你的回答。嗯,我们的老师不想让我们接触Tomcat目录中的context.xml文件。这就是为什么。我想知道为什么相同的代码在某些PC上不起作用,而每个工具都是相同的版本。。。。再次感谢你的回答。现在它工作了。嗨!谢谢你的回答。嗯,我们的老师不想让我们接触Tomcat目录中的context.xml文件。这就是为什么。我想知道为什么相同的代码在某些PC上不起作用,而每个工具都是相同的版本。。。。再次感谢你的回答。现在它起作用了。
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- The contents of this file will be loaded for each web application -->
<Context>
<!-- Default set of monitored resources. If one of these changes, the -->
<!-- web application will be reloaded. -->
<WatchedResource>WEB-INF/web.xml</WatchedResource>
<WatchedResource>${catalina.base}/conf/web.xml</WatchedResource>
<!-- Uncomment this to disable session persistence across Tomcat restarts -->
<!--
<Manager pathname="" />
-->
<Resource name="jdbc/myoracle" auth="Container"
type="javax.sql.DataSource" driverClassName="oracle.jdbc.OracleDriver"
url="jdbc:oracle:thin:@127.0.0.1:1521:mysid"
username="sijeune" password="oracle" maxTotal="20" maxIdle="10"
maxWaitMillis="-1"/>
</Context>
<resource-ref>
<description>Oracle Datasource example</description>
<res-ref-name>jdbc/myoracle</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>