zoukankan      html  css  js  c++  java
  • 搭建 maven 项目 搭建 maven web 项目及遇到 JDK 的问题

    临时起意搭建一个 maven web 项目。使用的servlet 3.0 及 1.8 JDK。

    maven 默认创建了一个JDK 1.5 版本的项目。

    注意此处选择一下WAR包。不然在配置中配置的话会有点点的小麻烦。

    然后开始更改JDK。。。

    还要把project facets 下的相关版本更改一下。

    同时,在maven项目下没有web.xml还需要新建目录,手动copy一个XML来。

    注意更改XML的使用模板版本。

    这个时候有个问题,还不能update项目,还需要更改pom文件中指定的JDK。有两种方式,一种做配置,另一种更改setting.xml

    <build>
            <finalName>careertalk</finalName>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>2.0.2</version>
                    <configuration>
                        <source>1.8</source>
                        <target>1.8</target>
                        <encoding>UTF-8</encoding>
                        <compilerArguments>
                            <verbose />
                   <!--双JDK 如果配有 JAVA_HOME JDK 用下面那个即可--> <bootclasspath>D:/Program Files/Java/jdk1.8.0_60/jre/lib/rt.jar</bootclasspath>
                    <!-- <bootclasspath>${java.home}/lib/rt.jar</bootclasspath> --> </compilerArguments> </configuration> </plugin> <plugin> <groupId>org.apache.tomcat.maven</groupId> <artifactId>tomcat7-maven-plugin</artifactId> <configuration> <path>/</path> <port>8083</port> </configuration> <version>2.2</version> </plugin> </plugins> </build>

    更改maven 的 setting.xml,在其中增加

    <profiles>
        <profile>
            <id>jdk-1.8</id>
            <!-- 另外一种激活方式 -->
            <activation>
                <activeByDefault>true</activeByDefault>
                <jdk>1.8</jdk>
            </activation>
            <properties>
                <maven.compiler.source>1.8</maven.compiler.source>
                <maven.compiler.target>1.8</maven.compiler.target>
    <maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
            </properties>
        </profile>
    </profiles>

     注意配置启动 tomcat 和 启动 JDK 

  • 相关阅读:
    CodeForces 706C Hard problem
    CodeForces 706A Beru-taxi
    CodeForces 706B Interesting drink
    CodeForces 706E Working routine
    CodeForces 706D Vasiliy's Multiset
    CodeForces 703B Mishka and trip
    CodeForces 703C Chris and Road
    POJ 1835 宇航员
    HDU 4907 Task schedule
    HDU 4911 Inversion
  • 原文地址:https://www.cnblogs.com/yeyuchangfeng/p/6830454.html
Copyright © 2011-2022 走看看