简体   繁体   English

必须在Intellij中将元素Web应用声明为错误

[英]Element web-app must be declared error in Intellij

I work in a project that I have a logback-test.xml file and the file shows error. 我在一个有logback-test.xml文件的项目中工作,该文件显示错误。 It's a multi-module maven project and the file mentioned is provided below, 这是一个多模块的maven项目,下面提供了提到的文件,

在此处输入图片说明

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_5.xsd"
         version="2.5">

  <configuration>
    <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
      <encoder>
        <pattern>%d [%t] %-5p %c:%L - %m%n</pattern>
      </encoder>
    </appender>

    <logger name="org.springframework" level="ERROR"/>
    <logger name="com.ratepay" level="ERROR"/>

    <root level="ERROR">
      <appender-ref ref="CONSOLE"/>
    </root>
  </configuration>
</web-app>

When I hold the cursor atop of the web-app tag, I get the error as Element web-app must be declared . 当我将光标停留在web-app标签的顶部时,由于Element web-app must be declared ,我得到了错误。 My colleague use the Eclipse and he doesn't have the same error. 我的同事使用Eclipse ,但没有相同的错误。

I have seen a few answers for the issue, but, can anyone clearly explain why does it see this? 我已经看到了该问题的一些答案,但是,谁能清楚地解释为什么会看到此问题?

Remove the following portion for logback.xml from the beginning. 从一开始就删除logback.xml的以下部分。

<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_5.xsd"
         version="2.5">

Remove the following portion from the last. 从最后删除以下部分。

</web-app>

It is not a web.xml which is deployment descriptor. 它不是作为部署描述符的web.xml。 logback.xml and web.xml are aparently different. logback.xml和web.xml显然有所不同。

In case of logback.xml, the final structure should be like this given below. 对于logback.xml,最终结构应如下所示。

<?xml version="1.0" encoding="UTF-8"?>

  <configuration>
    <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
      <encoder>
        <pattern>%d [%t] %-5p %c:%L - %m%n</pattern>
      </encoder>
    </appender>

    <logger name="org.springframework" level="ERROR"/>
    <logger name="com.ratepay" level="ERROR"/>

    <root level="ERROR">
      <appender-ref ref="CONSOLE"/>
    </root>
  </configuration>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 元素web-app必须在intellij中声明错误(java,springmvc,maven) - Element web-app must be declared error in intellij (java,springmvc,maven) 如何解决 Spring 中的 web-app 必须声明错误? - How to solve web-app must be declared error in Spring? maven web.xml 元素类型“web-app”必须由匹配的结束标记“”终止 - maven web.xml The element type "web-app" must be terminated by the matching end-tag "</web- app>" 如何在 intelliJ 中选择网络应用程序版本? - How can I choose web-app version in intelliJ? Oracle Weblogic:描述符文件中缺少根元素Web应用程序 - Oracle Weblogic: The root element web-app is missing in the descriptor file cvc-elt.1: 找不到元素 'web-app' 的声明 - cvc-elt.1: Cannot find the declaration of element 'web-app' 类必须声明为abstract或实现抽象方法:Intellij错误? - Class must either be declared abstract or implement abstract method: Intellij error? 在哪里可以找到web.xml中web-app元素的version属性的有效值? - Where i can find valid values for the version attribute of the web-app element in web.xml? 与元素类型“ web-app”相关联的属性“ xsi:schemaLocation”的前缀“ xsi”未绑定 - The prefix “xsi” for attribute “xsi:schemaLocation” associated with an element type “web-app” is not bound 休眠语法错误:必须为元素类型“ column”声明属性“ column” - Hibernate syntax error: Attribute “column” must be declared for element type “column”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM