Home>

The image is an image, but there are projects with the following directory structure.

where
① Execute>Maven Clean and
② Execute>Maven install was executed and a war file was generated.

The build will succeed, but it will be deployed on Tomcat
When checking from the browser, index.html gives 404 error.

Rename the war file to zip and unzip it.
Although files below META-INF and WEB-INF were included,
index.html was not included.

I thought it was a build setting, but I don't understand the cause.

In addition, this project seems to have built successfully on the developer's PC environment.
It seems to be caused by my environment (Java, Tomcat, Eclipse environment setting).

If i am aware of the cause, please reply or comment.

Also, in this way, place files such as static html and JavaScript in WebContent,
Explains how to create a project that can be accessed via a servlet
Just tell us about the website.

Thank you again.


Appendix

macOS High Sierra
Version 10.13.4

Eclipse IDE for Java Developers
Version: Photon Release (4.8.0)
Build id: 20180619-1200

$java -version
java version"1.8.0_181"
Java (TM) SE Runtime Environment (build 1.8.0_181-b13)
...

$/usr/local/tomcat8/bin/version.sh
...
Server version: Apache Tomcat/8.5.33
Server built: Aug 12 2018 08:20:08 UTC
...


pom.xml

<project xmlns = "http://maven.apache.org/POM/4.0.0" xmlns: xsi = "http://www.w3.org/ 2001/XMLSchema-instance "
    xsi: schemaLocation = "http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>xxxxx</groupId>
    <artifactId>xxxxx</artifactId>
    <version>xxxxx</version>
    <packaging>war</packaging>
    <name>xxxxx</name>
    <description>xxxxx</description>
    <dependencies>
        <dependency>
            <groupId>org.apache.tomcat</groupId>
            <artifactId>tomcat-el-api</artifactId>
            <version>8.5.9</version>
        </dependency>
        <dependency>
            <groupId>org.apache.tomcat</groupId>
            <artifactId>tomcat-i18n-es</artifactId>
            <version>8.5.9</version>
        </dependency>
        <dependency>
            <groupId>org.apache.tomcat</groupId>
            <artifactId>tomcat-websocket</artifactId>
            <version>8.5.9</version>
        </dependency>
        <dependency>
            <groupId>org.apache.tomcat</groupId>
            <artifactId>tomcat-jasper</artifactId>
            <version>8.5.9</version>
        </dependency>
        <dependency>
            <groupId>org.apache.tomcat</groupId>
            <artifactId>tomcat-jasper-el</artifactId>
            <version>8.5.9</version>
        </dependency>
        <dependency>
            <groupId>org.apache.tomcat</groupId><artifactId>tomcat-util</artifactId>
            <version>8.5.9</version>
        </dependency>
        <dependency>
            <groupId>org.apache.tomcat</groupId>
            <artifactId>tomcat-storeconfig</artifactId>
            <version>8.5.9</version>
        </dependency>
        <dependency>
            <groupId>org.apache.tomcat</groupId>
            <artifactId>tomcat-jsp-api</artifactId>
            <version>8.5.9</version>
        </dependency>
        <dependency>
            <groupId>org.apache.tomcat</groupId>
            <artifactId>tomcat-tribes</artifactId>
            <version>8.5.9</version>
        </dependency>
        <dependency>
            <groupId>org.apache.tomcat</groupId>
            <artifactId>tomcat-catalina</artifactId>
            <version>8.5.9</version>
        </dependency>
        <dependency>
            <groupId>org.apache.tomcat</groupId>
            <artifactId>tomcat-jni</artifactId>
            <version>8.5.9</version>
        </dependency>
        <dependency>
            <groupId>org.apache.tomcat</groupId>
            <artifactId>tomcat-websocket-api</artifactId>
            <version>8.5.9</version>
        </dependency>
        <dependency>
            <groupId>org.apache.tomcat</groupId>
            <artifactId>tomcat-coyote</artifactId>
            <version>8.5.9</version>
        </dependency>
        <dependency>
            <groupId>org.apache.tomcat</groupId>
            <artifactId>tomcat-catalina-ha</artifactId>
            <version>8.5.9</version>
        </dependency>
        <dependency>
            <groupId>org.apache.tomcat</groupId>
            <artifactId>tomcat-api</artifactId>
            <version>8.5.9</version>
        </dependency>
        <dependency>
            <groupId>org.apache.tomcat</groupId>
            <artifactId>tomcat-annotations-api</artifactId>
            <version>8.5.9</version>
        </dependency>
        <dependency>
            <groupId>org.apache.tomcat</groupId>
            <artifactId>tomcat-jaspic-api</artifactId>
            <version>8.5.9</version>
        </dependency>
        <dependency>
            <groupId>org.apache.tomcat</groupId>
            <artifactId>tomcat-catalina-ant</artifactId>
            <version>8.5.9</version>
        </dependency>
        <dependency>
            <groupId>org.apache.tomcat</groupId>
            <artifactId>tomcat-servlet-api</artifactId>
            <version>8.5.9</version>
        </dependency>
        <dependency>
            <groupId>org.apache.tomcat</groupId>
            <artifactId>tomcat-util-scan</artifactId>
            <version>8.5.9</version>
        </dependency><dependency>
            <groupId>org.apache.tomcat</groupId>
            <artifactId>tomcat-i18n-en</artifactId>
            <version>8.5.9</version>
        </dependency>
        <dependency>
            <groupId>org.eclipse.jdt.core.compiler</groupId>
            <artifactId>ecj</artifactId>
            <version>4.5.1</version>
        </dependency>
        <dependency>
            <groupId>org.apache.tomcat</groupId>
            <artifactId>tomcat-jdbc</artifactId>
            <version>8.5.9</version>
        </dependency>
        <dependency>
            <groupId>org.apache.tomcat</groupId>
            <artifactId>tomcat-i18n-fr</artifactId>
            <version>8.5.9</version>
        </dependency>
        <dependency>
            <groupId>org.apache.tomcat</groupId>
            <artifactId>tomcat-dbcp</artifactId>
            <version>8.5.9</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>4.3.11.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>4.3.11.RELEASE</version>
        </dependency>
    </dependencies>
    <build>
        <finalName>ROOT</finalName>
        <sourceDirectory>src</sourceDirectory>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.7.0</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-war-plugin</artifactId>
                <version>3.0.0</version>
                <configuration>
                    <warSourceDirectory>WebContent/build/default</warSourceDirectory>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

Warning related

Overriding managed version 1.10 for commons-codec pom.xml/yyyyy line 95 Maven pom loading problem
Overriding managed version 1.4.196 for h2 pom.xml/yyyyy line 135 Maven pom loading problem
Overriding managed version 2.4.12 for groovy-all pom.xml/yyyyy line 89 Maven pom loading problem
Overriding managed version 2.6.7.RELEASE for spring-data-rest-core pom.xml/yyyyy line 112 Maven pom loading problem
Overriding managed version 2.8.10 for jackson-datatype-hibernate4 pom.xml/yyyyy line 106 Maven pom loading problem
Overriding managed version 5.0.12.Final for hibernate-core pom.xml/yyyyy line 60 Maven pom loading problem
Overriding managed version 5.0.12.Final for hibernate-entitymanager pom.xml/yyyyy line 65 Maven pom loading problem
Overriding managed version 5.1.44 for mysql-connector-java pom.xml/yyyyy line 75 Maven pom loading problem
Unknown referenced nature: org.hibernate.eclipse.console.hibernateNature..project/yyyyy Unknown Unknown nature
Unknown referenced nature: org.jboss.tools.cdi.core.cdinature..project/xxxxx Unknown Unknown nature
Unknown referenced nature: org.jboss.tools.jst.web.kb.kbnature. .Project/xxxxx Unknown Unknown nature
  • Answer # 1

    Thank you for describing pom.xml.
    It seems to be caused by a mismatch between the maven-war-plugin setting and the built configuration.

    I don't understand the developer's environment, but the default configuration of Eclipse WTP (expanded under WebContent) is specified, but the default setting of maven-war-plugin is src/main/webapp Pack the following with war.

    https://maven.apache.org/plugins/maven-war-plugin/war-mojo.html

    In contrast,

    <warSourceDirectory>WebContent/build/default</warSourceDirectory>
    Since it is specified as

    , it seems to include the contents under WebContent/build/default.

    As you can see from the configuration of your project, the default setting of WTP is converted to a maven project.

    <warSourceDirectory>WebContent</warSourceDirectory>

  • Answer # 2

    Before buildingWebContent/build/default/The problem was solved by copying it below.
    I apologize to you for a fuss over. I'm sorry.