development

web.xml이 누락되었습니다

big-blog 2020. 6. 26. 07:47
반응형

web.xml이 누락되었습니다 true로 설정


치다:

여기에 이미지 설명을 입력하십시오

Eclipse 에서 간단한 Maven 프로젝트를 만들면 다음 오류가 발생합니다.

web.xml이 누락 <failOnMissingWebXml>되어 true로 설정되었습니다.

이 문제를 어떻게 해결할 수 있습니까?


다음과 같이 할 수도 있습니다.

  1. Project Explorer 에서 Deployment Descriptor마우스 오른쪽 버튼으로 클릭하십시오 .
  2. 배치 디스크립터 스텁 생성을 선택 하십시오 .

그것은 생성 WEB-INF에 있는 폴더 SRC / 메인 / 웹 애플리케이션web.xml을 거기에 있습니다.

여기에 이미지 설명을 입력하십시오


This is a maven error. It says that it is expecting a web.xml file in your project because it is a web application, as indicated by <packaging>war</packaging>. However, for recent web applications a web.xml file is totally optional. Maven needs to catch up to this convention. Add this to your maven pom.xml to let maven catch up and you don't need to add a useless web.xml to your project:

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.6</version>
            <configuration>
                <failOnMissingWebXml>false</failOnMissingWebXml>
            </configuration>
        </plugin>
    </plugins>
</build>

This is a better solution than adding an empty web.xml because this way your final product stays clean, your are just changing your build parameters.

For more current versions of maven you can also use the shorter version:

<properties>
    <failOnMissingWebXml>false</failOnMissingWebXml>
</properties>

If you already have web.xml under /src/main/webapp/WEB-INF but you still get error "web.xml is missing and is set to true", you could check if you have included /src/main/webapp in your project source.

Here are the steps you can follow:

  1. You can check this by right clicking your project, and open its Properties dialogue, and then "Deployment Assembly", where you can add Folder /src/main/webapp. Save the setting, and then,
  2. Go to Eclipse menu Project -> Clean... and clean the project, and the error should go away.

(I verified this with Eclipse Mars)


I have the same problem. After studying and googling, I have resolved my problem:

Right click on the project folder, go to Java EE Tools, select Generate Deployment Descriptor Stub. This will create web.xml in the folder src/main/webapp/WEB-INF.


If you use Spring Tool Suite, option for Generate Deployment Descriptor Stub is moved under Java EE Tools, so you:

  1. Right click on your project
  2. Select Java EE Tools
  3. Select Generate Deployment Descriptor Stub option

This will create web.xml file inside src/main/webapp/WEB-INF/ folder, and of course remove error from Maven's pom.xml file.

여기에 이미지 설명을 입력하십시오


You can also do this which is less verbose

<properties>
    <failOnMissingWebXml>false</failOnMissingWebXml>
</properties>

Eclipse recognizes incorrect default webapp directory. Therefore we should set clearly it by maven-war-plugin.

<build>
  <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-war-plugin</artifactId>
      <version>3.0.0</version>
      <configuration>
        <webappDirectory>src/main/webapp</webappDirectory>
      </configuration>
    </plugin>
  </plugins>
</build>

Once saving this setting, the error will never occour if removed it. (I cannot explain why.)


I had the same problem, even though I had 'src/main/webapp/WEB-INF/' folder with correct web.xml.

The problem disappeared after I recreated (maven->eclipse) configuration with Maven build.. I executed mvn eclipse:clean eclipse:eclipse

And then I used Maven -> Update Project to add (eclipse->maven) plugin specific options.


I encountered this issue in eclipse only, everything worked fine in Maven command line, and my web.xml file existed. It was a mature project (already deployed out in production) that was impacted. My problem was tied to the eclipse metadata. There was an issue with one of the files in my .settings/ folder, specifically org.eclipse.wst.common.component had been changed. I was able to restore this file to its prior version, which resolved the issue in my case.

Note that Yuci's answer did not work for me, when I tried to click on Deployment Assembly in the eclipse properties, I got an error that said "the currently displayed page contains invalid values."


Do this:

Go and right click on Deployment Descriptor and click Generate Deployment Descriptor Stub.


For Project with web.xml present Project-->Properties-->Deployment Assembly,where you can add Folder src/main/webapp. Save change. Clean the project to get going.

For Project with web.xml not present Set failOnMissingWebXml to false in pom.xml under properties tag.


It doesn't make sense to create a web.xml just elcipse wants it, even there is no need. This is the case if you have servlet conatiner embedded or living without xml cfg like spring-boot does. The you just diable JavaEE (useless stuff) in eclipse on project level or global

Eclipse/STS>Windows>Preferences>JavaEE>Doclet>Webdoclet> "uncheck" DeploymentDescriptor > OK

Select your project and select the "Deployment Descriptor" option and then choose "Generate Deployment Descriptor stub"


The step of : Select your project and select the "Deployment Descriptor" option and then choose "Generate Deployment Descriptor stub" works fine. The issue is that it is not always the case that we need web.xml, so it is best to append false to pom.xml


Create WEB-INF folder in src/webapp, and include web.xml page inside the WEB-INF folder then


-web / .setting & -admin / .setting 에서 파일을 제거하십시오.

1


프로젝트를 마우스 오른쪽 버튼으로 클릭하고 Maven-> Update Project ... 로 이동 한 다음 Force Snapshots / Releases 강제 업데이트 를 확인한 다음 Ok 를 클릭하십시오 . 끝났다!

참고 URL : https://stackoverflow.com/questions/31835033/web-xml-is-missing-and-failonmissingwebxml-is-set-to-true

반응형