您好,欢迎访问成都祈钰瑶科技有限公司!

全国咨询热线

18982081108
✕

成都网站建设公司,成都网站UI设计,成都网站安全维护,成都网站内容优化服务

Maven常规错误一览及解决方案-创新互联

更新信息

创新互联建站网站建设由有经验的网站设计师、开发人员和项目经理组成的专业建站团队,负责网站视觉设计、用户体验优化、交互设计和前端开发等方面的工作,以确保网站外观精美、成都网站制作、成都网站设计易于使用并且具有良好的响应性。

2016-03-13 开贴

想法很单纯,将自己在Maven学习过程中遇到的各种麻烦列出来,并提供解决方案待查。

正题开始,遇到错误可通过报错信息对号入座:

错误提示:web.xml is missing and <failOnMissingWebXml> is set to true

推测原因:这是maven自身的错误。意思是你的web应用项目中缺少web.xml文件,但是如今web.xml在众多的web应用项目中已成为可有可无的存在。但maven还是将此视为必须。

解决方案:加入以下代码到你的pom.xml文件中,不需要创建那个无用的web.xml

<build>
  <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-war-plugin</artifactId>
      <version>2.6</version>
      <configuration>
        <failOnMissingWebXml>false</failOnMissingWebXml>
      </configuration>
    </plugin>
  </plugins>
</build>

错误提示:Dynamic Web Module 3.0 requires Java 1.6 or newer

推测原因:无非是项目中Project Facets的Dynamic Web Module和Java版本对应不一致造成。调整Dynamic Web Module的版本时,底部会有相应提示。

解决方案:根据调整Java版本号即可,也可以修改pom.xml,告诉Maven编译时需要的Java版本

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

错误提示:Plugin execution not covered by lifecycle configuration

推测原因:eclipse的m2e插件还没有支持到execution

参考:https://www.eclipse.org/m2e/documentation/m2e-execution-not-covered.html

解决方案:在<plugins>标签添加上级标签<pluginsManagement>

<pluginManagement>
    <plugins>
        <plugin>
            <groupId>org.mybatis.generator</groupId>
            <artifactId>mybatis-generator-maven-plugin</artifactId>
            <version>1.3.2</version>
            <executions>
                <execution>
                    <id>generate-sources</id>
                    <goals>
                        <goal>generate</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</pluginManagement>

另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。