zoukankan      html  css  js  c++  java
  • eclipse新建maven web工程

    每次建maven项目,总会有问题。决定在这整理一次,避免以后浪费时间。

    最后目录为

     1.首先修改pom.xml

    之前老是出现明明改了 java compiler 已maven update 一下就又变回来的情况 例如这种错误:

    Dynamic Web Module 3.0 requires Java 1.6 or newer.
    Java compiler level does not match the version of the installed Java project facet.
    One or more constraints have not been satisfied.(被这个错误折磨好久,每次新建maven项目都要弄好久)

    在加上下面代码就好了,因为1:maven 2.1默认用jdk 1.3来编译,maven 3 是用jdk 1.5,如果项目用的jdk 1.7也会有问题,compiler插件可以指定JDK版本为1.7。 

    compiler插件能解决: 
     
    <build>
    		<finalName>Maven</finalName>
    		<pluginManagement>
    			<plugins>
    				<!-- 编译器版本 -->
    				<plugin>
    					<groupId>org.apache.maven.plugins</groupId>
    					<artifactId>maven-compiler-plugin</artifactId>
    					<version>3.0</version>
    					<configuration>
    						<source>1.7</source>
    						<target>1.7</target>
    					</configuration>
    				</plugin>
    			</plugins>
    		</pluginManagement>
    	</build>
    

    2.修改java compiler

    保存之后发现 目录变多了

    删除了faces-config.xml,然后打开web.xml

    然后 项目右键--maven--update project 就发现项目不报错了。

    3.新建了jsp文件 报错了,是因为有包没导入

    在pom.xml中加入下面代码 就好了。

     <dependencies>
          <!-- 导入java ee jar 包 -->
        <dependency>
                <groupId>javax</groupId>
                <artifactId>javaee-api</artifactId>
                <version>7.0</version>
            </dependency>
      </dependencies>

    反复试验了好多遍 是ok的,如果有更好的方法请告知啦。

  • 相关阅读:
    我的PC必装软件
    NumPy数值计算(1)
    英文标题首字母大写规则
    学渣笔记之矩阵的导数与迹
    测试
    (英文排版测试)Lorem Ipsum
    XeLaTeX插入GB/T 7714-2005规范的参考文献方法
    linux-centos7 下 php 扩展的 编译与安装,以 mysqli 为例
    linux-centos7-vmware 实现与虚拟机共享文件夹宿主机磁盘文件
    linux-centos7 下安装 php-nginx 服务器
  • 原文地址:https://www.cnblogs.com/wangxiaomei/p/6215551.html
Copyright © 2011-2022 走看看