画像は、イメージですが、以下のようなディレクトリ構成のプロジェクトがあります。
ここで、
① 実行 > Maven Clean と、
② 実行 > Maven install を実行しwarファイルを生成しました。
すると、ビルドは成功するのですが、Tomcatで展開し
ブラウザから確認したとき、index.htmlが404エラーになります。
warファイルをzipにリネームし、解凍したところ、
META-INFとWEB-INF以下のファイルは含まれていたものの、
index.htmlは含まれていませんでした。
ビルドのときの設定かなと思いましたが、原因が分かりません。
また、このプロジェクトは、開発者のPC環境では正常にビルドできていたようで、
私の環境(Java?Tomcat?Eclipseの環境設定?)が原因のようにも思います。
原因に関して、お心当たりのある方おられましたら、回答・コメントお願いします。
また、このように、WebContent内に静的なhtmlやJavaScriptなどのファイルを配置し、
サーブレットを介してアクセスするようなプロジェクトの作り方を解説しているような
Webサイトを教えていただくだけでもかまいません。
重ねてよろしくお願いします。
追記
macOS High Sierra
バージョン 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
xml
1<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 2 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 3 <modelVersion>4.0.0</modelVersion> 4 <groupId>xxxxx</groupId> 5 <artifactId>xxxxx</artifactId> 6 <version>xxxxx</version> 7 <packaging>war</packaging> 8 <name>xxxxx</name> 9 <description>xxxxx</description> 10 <dependencies> 11 <dependency> 12 <groupId>org.apache.tomcat</groupId> 13 <artifactId>tomcat-el-api</artifactId> 14 <version>8.5.9</version> 15 </dependency> 16 <dependency> 17 <groupId>org.apache.tomcat</groupId> 18 <artifactId>tomcat-i18n-es</artifactId> 19 <version>8.5.9</version> 20 </dependency> 21 <dependency> 22 <groupId>org.apache.tomcat</groupId> 23 <artifactId>tomcat-websocket</artifactId> 24 <version>8.5.9</version> 25 </dependency> 26 <dependency> 27 <groupId>org.apache.tomcat</groupId> 28 <artifactId>tomcat-jasper</artifactId> 29 <version>8.5.9</version> 30 </dependency> 31 <dependency> 32 <groupId>org.apache.tomcat</groupId> 33 <artifactId>tomcat-jasper-el</artifactId> 34 <version>8.5.9</version> 35 </dependency> 36 <dependency> 37 <groupId>org.apache.tomcat</groupId> 38 <artifactId>tomcat-util</artifactId> 39 <version>8.5.9</version> 40 </dependency> 41 <dependency> 42 <groupId>org.apache.tomcat</groupId> 43 <artifactId>tomcat-storeconfig</artifactId> 44 <version>8.5.9</version> 45 </dependency> 46 <dependency> 47 <groupId>org.apache.tomcat</groupId> 48 <artifactId>tomcat-jsp-api</artifactId> 49 <version>8.5.9</version> 50 </dependency> 51 <dependency> 52 <groupId>org.apache.tomcat</groupId> 53 <artifactId>tomcat-tribes</artifactId> 54 <version>8.5.9</version> 55 </dependency> 56 <dependency> 57 <groupId>org.apache.tomcat</groupId> 58 <artifactId>tomcat-catalina</artifactId> 59 <version>8.5.9</version> 60 </dependency> 61 <dependency> 62 <groupId>org.apache.tomcat</groupId> 63 <artifactId>tomcat-jni</artifactId> 64 <version>8.5.9</version> 65 </dependency> 66 <dependency> 67 <groupId>org.apache.tomcat</groupId> 68 <artifactId>tomcat-websocket-api</artifactId> 69 <version>8.5.9</version> 70 </dependency> 71 <dependency> 72 <groupId>org.apache.tomcat</groupId> 73 <artifactId>tomcat-coyote</artifactId> 74 <version>8.5.9</version> 75 </dependency> 76 <dependency> 77 <groupId>org.apache.tomcat</groupId> 78 <artifactId>tomcat-catalina-ha</artifactId> 79 <version>8.5.9</version> 80 </dependency> 81 <dependency> 82 <groupId>org.apache.tomcat</groupId> 83 <artifactId>tomcat-api</artifactId> 84 <version>8.5.9</version> 85 </dependency> 86 <dependency> 87 <groupId>org.apache.tomcat</groupId> 88 <artifactId>tomcat-annotations-api</artifactId> 89 <version>8.5.9</version> 90 </dependency> 91 <dependency> 92 <groupId>org.apache.tomcat</groupId> 93 <artifactId>tomcat-jaspic-api</artifactId> 94 <version>8.5.9</version> 95 </dependency> 96 <dependency> 97 <groupId>org.apache.tomcat</groupId> 98 <artifactId>tomcat-catalina-ant</artifactId> 99 <version>8.5.9</version> 100 </dependency> 101 <dependency> 102 <groupId>org.apache.tomcat</groupId> 103 <artifactId>tomcat-servlet-api</artifactId> 104 <version>8.5.9</version> 105 </dependency> 106 <dependency> 107 <groupId>org.apache.tomcat</groupId> 108 <artifactId>tomcat-util-scan</artifactId> 109 <version>8.5.9</version> 110 </dependency> 111 <dependency> 112 <groupId>org.apache.tomcat</groupId> 113 <artifactId>tomcat-i18n-ja</artifactId> 114 <version>8.5.9</version> 115 </dependency> 116 <dependency> 117 <groupId>org.eclipse.jdt.core.compiler</groupId> 118 <artifactId>ecj</artifactId> 119 <version>4.5.1</version> 120 </dependency> 121 <dependency> 122 <groupId>org.apache.tomcat</groupId> 123 <artifactId>tomcat-jdbc</artifactId> 124 <version>8.5.9</version> 125 </dependency> 126 <dependency> 127 <groupId>org.apache.tomcat</groupId> 128 <artifactId>tomcat-i18n-fr</artifactId> 129 <version>8.5.9</version> 130 </dependency> 131 <dependency> 132 <groupId>org.apache.tomcat</groupId> 133 <artifactId>tomcat-dbcp</artifactId> 134 <version>8.5.9</version> 135 </dependency> 136 <dependency> 137 <groupId>org.springframework</groupId> 138 <artifactId>spring-web</artifactId> 139 <version>4.3.11.RELEASE</version> 140 </dependency> 141 <dependency> 142 <groupId>org.springframework</groupId> 143 <artifactId>spring-webmvc</artifactId> 144 <version>4.3.11.RELEASE</version> 145 </dependency> 146 </dependencies> 147 <build> 148 <finalName>ROOT</finalName> 149 <sourceDirectory>src</sourceDirectory> 150 <plugins> 151 <plugin> 152 <artifactId>maven-compiler-plugin</artifactId> 153 <version>3.7.0</version> 154 <configuration> 155 <source>1.8</source> 156 <target>1.8</target> 157 </configuration> 158 </plugin> 159 <plugin> 160 <artifactId>maven-war-plugin</artifactId> 161 <version>3.0.0</version> 162 <configuration> 163 <warSourceDirectory>WebContent/build/default</warSourceDirectory> 164 </configuration> 165 </plugin> 166 </plugins> 167 </build> 168</project>
関係のありそうなWarning
Overriding managed version 1.10 for commons-codec pom.xml /yyyyy 行 95 Maven pom ロード問題 Overriding managed version 1.4.196 for h2 pom.xml /yyyyy 行 135 Maven pom ロード問題 Overriding managed version 2.4.12 for groovy-all pom.xml /yyyyy 行 89 Maven pom ロード問題 Overriding managed version 2.6.7.RELEASE for spring-data-rest-core pom.xml /yyyyy 行 112 Maven pom ロード問題 Overriding managed version 2.8.10 for jackson-datatype-hibernate4 pom.xml /yyyyy 行 106 Maven pom ロード問題 Overriding managed version 5.0.12.Final for hibernate-core pom.xml /yyyyy 行 60 Maven pom ロード問題 Overriding managed version 5.0.12.Final for hibernate-entitymanager pom.xml /yyyyy 行 65 Maven pom ロード問題 Overriding managed version 5.1.44 for mysql-connector-java pom.xml /yyyyy 行 75 Maven pom ロード問題 Unknown referenced nature: org.hibernate.eclipse.console.hibernateNature. .project /yyyyy 不明 Unknown nature Unknown referenced nature: org.jboss.tools.cdi.core.cdinature. .project /xxxxx 不明 Unknown nature Unknown referenced nature: org.jboss.tools.jst.web.kb.kbnature. .project /xxxxx 不明 Unknown nature
回答2件
あなたの回答
tips
プレビュー