URI 未在 applicationContext.xml 中注册(设置 | 语言和框架 | 架构和 DTD)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/42569634/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-06 12:12:29  来源:igfitidea点击:

URI is not registered (Settings | Languages & Frameworks | Schemas and DTDs) in applicationContext.xml

xmlintellij-idea

提问by qg_java_17137

I created an application Context.xml at the WEB-INF/classesdirectory. and I have added the <!DOCTYPE>in the xml. I am getting the below error:

我在该WEB-INF/classes目录中创建了一个应用程序 Context.xml 。我<!DOCTYPE>在 xml 中添加了。我收到以下错误:

URI is not registered (Settings | Languages & Frameworks | Schemas and DTDs)

URI 未注册(设置 | 语言和框架 | 架构和 DTD)

You can see the snapshot below:

您可以在下面看到快照:

enter image description here

在此处输入图片说明

The xml is below:

xml如下:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">  // -> there comes the issue
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">

</beans>

回答by aircraft

You can easy solve it by: Fetch external resource.

您可以通过以下方式轻松解决:获取外部资源。

Click the light(your is red) -> Fetch external resource.

单击灯(您的是红色)-> 获取外部资源。

回答by BamaPookie

I'm assuming this is in IntelliJ IDEA or some other JetBrains tool. If you place the cursor over the URL (or select it), you should see a red bulb on the left border of the window. That red bulb, when clicked, will give you some options to correct any errors. One of the options should be to download the DTD (Fetch external resource). Do that and the error should go away.

我假设这是在 IntelliJ IDEA 或其他一些 JetBrains 工具中。如果您将光标放在 URL 上(或选择它),您应该会在窗口的左边框上看到一个红色灯泡。单击该红色灯泡时,将为您提供一些选项来纠正任何错误。选项之一应该是下载 DTD(获取外部资源)。这样做,错误就会消失。

回答by Thomas

For me Build > Clean Projectworked.

对我来说Build > Clean Project有效。

回答by Grandtour

This did the work:

这完成了工作:

Alt+Enter-> Fetch external resource

Alt+ Enter-> 获取外部资源

回答by Gangnus

Times change and Apache simply does not support that 1.xx version of log4j anymore. That XML really is not there on that address.

时代在变,Apache 不再支持 1.xx 版本的 log4j。该 XML 确实不在该地址上。

log4jis dead. Long live log4j2!
Look here: https://logging.apache.org/log4j/2.x/manual/migration.html.

log4j死了。万岁log4j2
看这里:https: //logging.apache.org/log4j/2.x/manual/migration.html

New configuration language is shorter and more convenient:

新的配置语言更短更方便:

<?xml version="1.0" encoding="UTF-8"?>
<Configuration>
  <Appenders>
    <Console name="STDOUT" target="SYSTEM_OUT">
      <PatternLayout pattern="%d %-5p [%t] %C{2} (%F:%L) - %m%n"/>
    </Console>
  </Appenders>
  <Loggers>
    <Logger name="org.apache.log4j.xml" level="info"/>
    <Root level="debug">
      <AppenderRef ref="STDOUT"/>
    </Root>
  </Loggers>
</Configuration>

If you feel you must use the old version, you should download the old XML that lived at the old address, put it on your server and use the new address.

如果您觉得必须使用旧版本,则应下载旧地址中的旧 XML,将其放在您的服务器上并使用新地址。

回答by Saikat

If you select and hit ALT+ENTERi.e. More Actions...then following options would be displayed:

如果您选择并点击ALT+ ENTERie,More Actions...则会显示以下选项:

1. Add xsi schema location for external resource
2. Fetch external resource
3. Ignore external resource
4. Manually setup external resource

Most of the times you would either select option no. 2 or 3 to get rid of this error.

大多数情况下,您要么选择选项 no。2 或 3 来摆脱这个错误。

回答by Aleksey Wert

If "fetch" does not help, it means You have created this xml-file as empty file with .xml extention and filled config manually. Now delete it and recreate it propperly as "Spring config" file from template.

如果“获取”没有帮助,则表示您已将此 xml 文件创建为带有 .xml 扩展名的空文件并手动填充了配置。现在删除它并从模板中正确地将其重新创建为“Spring 配置”文件。

回答by Darush

In my case, I was opening XML resource files from debugbuild variant while my Android Studio had betabuild variant selected.

就我而言,我从调试构建变体打开 XML 资源文件,而我的 Android Studio选择了beta构建变体。

I switched to the debugbuild variant (to which the XML file belonged) and voila! errors gone.

我切换到调试构建变体(XML 文件所属的变体),瞧!错误消失了。

enter image description here

在此处输入图片说明