必须在Intellij

时间:2019-05-27 14:10:30

标签: java xml intellij-idea web-applications

我在一个有logback-test.xml文件的项目中工作,该文件显示错误。这是一个多模块的maven项目,下面提供了提到的文件,

enter image description here

<?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>

将光标放在web-app标记上方时,我得到的错误为Element web-app must be declared。我的同事使用Eclipse,但他没有相同的错误。

我已经看到了该问题的一些答案,但是,谁能清楚地解释为什么会看到此问题?

1 个答案:

答案 0 :(得分:1)

从一开始就删除logback.xml的以下部分。

<div>
  <div class="myDiv">Textarea</div>
  <textarea class="myTextarea" rows="1">12345</textarea>
  <div class="myDiv">Input</div>
  <input class="myInput" type="text" value="12345"/>
</div>

从最后删除以下部分。

<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">

它不是web.xml,而是部署描述符。 logback.xml和web.xml显然有所不同。

对于logback.xml,最终结构应如下所示。

</web-app>
相关问题