Maven更新项目在工作区中提供了多个错误

时间:2023-01-27 10:44:18

I am trying to create a Simple MVC project. I am using JBOSS developer studio(Version: 10.0.0.GA), and Red Hat JBoss EAP 7.0, m2e eclipse plugin,Java version: 1.8.0_91. I after creating a simple project by selecting a architect type, I did necessary spring configuration. Attached the code below. Then I gave maven update project. Which resulted in multiple errors. I referred other stack overflow solutions to resolve them. But nothing helped me. Can anyone help me to resolve the issues.

我正在尝试创建一个简单的MVC项目。我使用的是JBOSS developer studio(版本:10.0.0.GA)和Red Hat JBoss EAP 7.0,m2e eclipse插件,Java版本:1.8.0_91。我通过选择架构师类型创建一个简单的项目后,我做了必要的弹簧配置。附上下面的代码。然后我给了maven更新项目。这导致了多个错误。我提到了其他堆栈溢出解决方案来解决它们。但没有任何帮助我。任何人都可以帮我解决问题。

Errors:

1) Cannot change version of project facet Dynamic Web Module to 3.0. Replenishment

1)无法将项目方面动态Web模块的版本更改为3.0。补货

2) JavaServer Faces 2.2 requires Dynamic Web Module 2.5 or newer. Replenishment

2)JavaServer Faces 2.2需要动态Web模块2.5或更高版本。补货

pom.xml

    <project xmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>au.com.mercury</groupId>
    <artifactId>Replenishment</artifactId>
    <packaging>war</packaging>
    <version>0.0.1-SNAPSHOT</version>
    <name>Replenishment Maven Webapp</name>
    <url>http://maven.apache.org</url>
    <dependencies>
    <dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>3.8.1</version>
    <scope>test</scope>
    </dependency>
    <!-- spring-context which provides core functionality -->
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>4.1.6.RELEASE</version>
    </dependency>

    <!-- The spring-aop module provides an AOP Alliance-compliant aspect-oriented 
        programming implementation allowing you to define -->
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-aop</artifactId>
        <version>4.1.6.RELEASE</version>
    </dependency>

    <!-- The spring-webmvc module (also known as the Web-Servlet module) contains 
        Spring’s model-view-controller (MVC) and REST Web Services implementation 
        for web applications -->
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>4.1.6.RELEASE</version>
    </dependency>

    <!-- The spring-web module provides basic web-oriented integration features 
        such as multipart file upload functionality and the initialization of the 
        IoC container using Servlet listeners and a web-oriented application context -->
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-web</artifactId>
        <version>4.1.6.RELEASE</version>
    </dependency>

  </dependencies>
  <build>
    <finalName>Replenishment</finalName>
  </build>
</project>

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>CrunchifySpringMVCTutorial</display-name>
  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>
  <servlet>
    <servlet-name>spring</servlet-name>
    <servlet-class>
            org.springframework.web.servlet.DispatcherServlet
        </servlet-class>
    <init-param>
      <param-name>contextConfigLocation</param-name>
      <param-value>/WEB-INF/spring-servlet.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>spring</servlet-name>
    <url-pattern>*</url-pattern>
  </servlet-mapping>
  <servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>/faces/*</url-pattern>
  </servlet-mapping>
</web-app>

facet.core.xml

<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
  <runtime name="Red Hat JBoss EAP 7.0 Runtime"/>
  <fixed facet="wst.jsdt.web"/>
  <installed facet="jst.web" version="3.0"/>
  <installed facet="wst.jsdt.web" version="1.0"/>
  <installed facet="java" version="1.8"/>
  <installed facet="jst.jaxrs" version="2.0"/>
  <installed facet="jst.jsf" version="2.2"/>
</faceted-project>

SampleController.java

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;


@Controller
public class SampleController {

    @RequestMapping("/welcome")
    public ModelAndView helloWorld() {

        String message = "<br><div style='text-align:center;'>"
                + "<h3>********** Hello World, Spring MVC Tutorial</h3>This message is coming from CrunchifyHelloWorld.java **********</div><br><br>";
        return new ModelAndView("welcome", "message", message);
    }

}

spring-servlet.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:context="http://www.springframework.org/schema/context"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="
        http://www.springframework.org/schema/beans     
        http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/mvc 
        http://www.springframework.org/schema/mvc/spring-mvc.xsd
        http://www.springframework.org/schema/context 
        http://www.springframework.org/schema/context/spring-context.xsd">

    <context:component-scan base-package="au.com.woolworths.mercury.controller" />

    <bean id="viewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver">
        <property name="viewClass" value="org.springframework.web.servlet.view.JstlView" />
        <property name="prefix" value="/WEB-INF/jsp/" />
        <property name="suffix" value=".jsp" />
    </bean>

</beans>

Errors & Project facets

错误和项目方面

1 个解决方案

#1


1  

After adding the maven build plugin and maven compiler plugin with appropriate version of Java, the error(s) got resolved.

在使用适当版本的Java添加maven构建插件和maven编译器插件后,错误得到了解决。

<build>
    <finalName>Replenishment</finalName>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.6</version>
        </plugin>
    </plugins>
  </build>

#1


1  

After adding the maven build plugin and maven compiler plugin with appropriate version of Java, the error(s) got resolved.

在使用适当版本的Java添加maven构建插件和maven编译器插件后,错误得到了解决。

<build>
    <finalName>Replenishment</finalName>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.6</version>
        </plugin>
    </plugins>
  </build>