初学Maven搭建Web项目问题汇总

1:Maven项目,右键-update project后报错
解决办法:在pom.xml配置文件中加入如下语句:
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7(修改成自己JDK的版本)</source>
<target>1.7(修改成自己JDK的版本)</target>
</configuration>
</plugin>
</plugins>

2:报错:Cannot change version of project facet Dynamic Web Module to 3.0
1)修改\WEB-INF\web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://java.sun.com/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>
2)修改org.eclipse.jdt.core.prefs
1.8

3)修改org.eclipse.wst.common.component
1.8.0

4)修改org.eclipse.wst.common.project.facet.core.xml
3.1

5)配置maven setting.xml

<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>


6)修改项目pom.xml

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>

7)Maven->Update Project


3:加载到tomcat容器中,修改pom.xml
<build>
        <finalName>hunhr</finalName>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.2</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                    <encoding>UTF-8</encoding>
                    <container>
                        <containerId>tomcat8</containerId>
                        <home>F:\Tools\apache-tomcat-8.0.53</home>
                    </container>
                    <configuration>
                        <type>existing</type>
                        <home>F:\Tools\apache-tomcat-8.0.53</home>
                    </configuration>
                </configuration>
                <executions>
                    <execution>
                        <id>cargo-run</id>
                        <phase>install</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值