zoukankan      html  css  js  c++  java
  • 使用eclipse创建一个简单的Java Web应用程序

      关于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项目结构:

       运行结果:

  • 相关阅读:
    Parameter Binding in ASP.NET Web API
    Which HTTP methods match up to which CRUD methods?
    ErrorHandling in asp.net web api
    HttpStatusCode
    Autofac Getting Started(默认的构造函数注入)
    Autofac Controlling Scope and Lifetime
    luvit 被忽视的lua 高性能框架(仿nodejs)
    undefined与null的区别
    VsCode中使用Emmet神器快速编写HTML代码
    字符串匹配---KMP算法
  • 原文地址:https://www.cnblogs.com/darkchii/p/8642284.html
Copyright © 2011-2022 走看看