關於Java JDK/JRE、Tomcat的配置等等都沒什么好說的,主要記錄一下使用Eclipse創建web工程時的一些點以及說一說自己用IDEA的創建失敗的過程(IDEA沒運行成功。。。暫時不想弄了)。
先說說IDEA吧。本來用的又是社區版,所以不支持tomcat,於是只有通過maven在中央倉庫下載tomcat8-maven-plugin插件來使用tomcat,也就是說主要問題就是pom.xml配置文件的問題,網上找了好多tomcat插件,總算把所有錯誤都消除了,還有一些compile插件,但最后都沒有build成功,給看看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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>darkchii</groupId>
<artifactId>AnimeWeb</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>AnimeWeb Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<pluginRepositories>
<pluginRepository>
<id>alfresco-public</id>
<url>https://artifacts.alfresco.com/nexus/content/groups/public</url>
</pluginRepository>
<pluginRepository>
<id>alfresco-public-snapshots</id>
<url>https://artifacts.alfresco.com/nexus/content/groups/public-snapshots</url>
<snapshots>
<enabled>true</enabled>
<updatePolicy>daily</updatePolicy>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>beardedgeeks-releases</id>
<url>http://beardedgeeks.googlecode.com/svn/repository/releases</url>
</pluginRepository>
</pluginRepositories>
<build>
<defaultGoal>compile</defaultGoal>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12.3</version>
<configuration>
<groups>unit</groups>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<verbose>true</verbose>
<fork>true</fork>
<compilerVersion>1.5</compilerVersion>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat8-maven-plugin</artifactId>
<version>3.0-r1756463</version>
<configuration>
<path>/</path>
<uriEncoding>UTF-8</uriEncoding>
<server>tomcat8</server>
</configuration>
</plugin>
</plugins>
</build>
</project>
於是轉向用idea試用版,這個因為配置都是齊全的,所以創建過程都沒什么問題,之后就是運行,結果還是運行失敗了,報錯誤:
Error:during artifact deloyment.
網上查資料,都說是Artifact沒配置好,但我的都是配置好的。沒深入研究,暫時沒找到解決方案。
接下來說說eclipse,用她的時候輕松很多,創建過程也不復雜,運行也良好。。。所以寫到這里,突然感覺創建過程也沒啥好說的。。。網上也都有詳細的教程。。。emmm,我想想有沒有什么值得注意的地方可以說...感覺設置超時應該值得注意,如果只是一個簡單的demo Web程序可能不會超時(一般默認為45s),但如果是一個比較復雜的web項目,那么就需要注意這一點了,還有就是注意編碼問題,有些IDE的jsp文件編碼默認不是utf-8等等。
給看看我自己的一個簡單的demo web項目結構:

運行結果:

