zoukankan      html  css  js  c++  java
  • 对于eclipse新建maven工程需要注意的地方。

    新建项目的时候,如果想配置默认的maven的jre为1.6或者别的。

    http://hi.baidu.com/hi_hi/item/765ec8bbc49880d384dd79d1

    1.cmd命令建立web项目:mvn archetype:generate -DgroupId=biz.yunduo -DartifactId=dts -DpackageName=dts -DarchetypeArtifactId=maven-archetype-webapp

    2.如下图,eclipse3.6 For javaEE下有个警告,意思是项目Build path指定的jre是j2se1.5但是找不到与此版本严格匹配的jre

    47359f50a461773184352461[1]

    3.纠结了好长时间,不如看看maven的配置文件吧。打开%maven_home%confsetting.xml

    在<profiles>标签内添加如下配置:

    <profile>
     <id>jdk-1.6</id>
     <activation>
      <activeByDefault>true</activeByDefault>
      <jdk>1.6</jdk>
     </activation>
     <properties>
      <maven.compiler.source>1.6</maven.compiler.source>
      <maven.compiler.target>1.6</maven.compiler.target>
      <maven.compiler.compilerVersion>1.6</maven.compiler.compilerVersion>
     </properties>
    </profile>

    以后再使用maven生成项目默认编译级别就是1.6的了

    4.如果你有特别的需要,比如不同的项目使用的jre不同那么可以在项目的pom.xml里添加如下配置:

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>
        </plugins>
    </build>

    上面的是默认的。如果,想修改已经创建好的maven项目的jre和Web Module Version要修改项目Location下面的org.eclipse.wst.common.project.facet.core.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <faceted-project>
      <fixed facet="wst.jsdt.web"/>
      <installed facet="jst.web" version="3.0"/>
      <installed facet="wst.jsdt.web" version="1.0"/>
      <installed facet="jst.jaxrs" version="1.1"/>
      <installed facet="java" version="1.7"/>
    </faceted-project>
    同时,要修改web.xml里的web-app内容
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns="http://xmlns.jcp.org/xml/ns/javaee" 
        xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd "
        version="3.0">
        <display-name>Archetype Created Web Application</display-name>
    </web-app>

    关于遇到The import javax.servlet.annotation cannot be resolved的问题,是因为支持annotation需要下面的版本javax.servlet

    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>javax.servlet-api</artifactId>
        <version>3.0.1</version>
    </dependency>

  • 相关阅读:
    [转]Android应用开发提高系列(5)——Android动态加载(下)——加载已安装APK中的类和资源
    [转]Eclipse中配置Struts2并实现HelloWorld
    [转]android4.0.3 修改启动动画和开机声音
    版本管理 Git
    [转]Android动态加载jar/dex
    [转]JSP 9 大内置对象详解
    [转]TMX Map Format Tiled地图格式
    [转]C++按行读取文本文件
    [转]Java——Servlet的配置和测试
    [转]android条形码编解码
  • 原文地址:https://www.cnblogs.com/sunhan/p/3800812.html
Copyright © 2011-2022 走看看