【问题标题】:I'm creating a maven project and I'm a beginner..I got this error. can help to resolve this is my pom.xml & web.xml [duplicate]我正在创建一个 Maven 项目,我是初学者..我收到了这个错误。可以帮助解决这是我的 pom.xml 和 web.xml [重复]
【发布时间】:2018-04-17 08:05:36
【问题描述】:

http://maven.apache.org/maven-v4_0_0.xsd"> 4.0.0 com.project Online_Medical_Reporting_System 战争 0.0.1-快照 Online_Medical_Reporting_System Maven Webapp http://maven.apache.org 朱尼特 朱尼特 3.8.1 测试 org.hibernate.javax.persistence 休眠-jpa-2.1-api 1.0.0.Final org.hibernate 休眠验证器 4.0.2.GA org.hibernate 休眠核心 3.3.2.GA org.springframework spring-aop 4.1.6.发布

    <!-- 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>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>4.2.4.RELEASE</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.springframework/spring-tx -->
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-tx</artifactId>
        <version>4.0.4.RELEASE</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/org.springframework/spring-beans -->
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-beans</artifactId>
        <version>4.3.0.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-jdbc</artifactId>
        <version>4.3.1.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
        <version>1.2.17</version>
    </dependency>
</dependencies>
<build>
    <finalName>Online_Medical_Reporting_System</finalName>
    <plugins>
        <plugin>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-maven-plugin</artifactId>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.2</version>
            <configuration>
                <verbose>true</verbose>
                <source>1.7</source>
                <target>1.7</target>
                <showWarnings>true</showWarnings>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.tomcat.maven</groupId>
            <artifactId>tomcat7-maven-plugin</artifactId>
            <version>2.2</version>
            <configuration>
                <path>/</path>
                <contextReloadable>true</contextReloadable>
            </configuration>
        </plugin>

    </plugins>
</build>

块引用

http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" 版本="3.0"> Online_Medical_Reporting_System

<listener>
    <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>
<servlet>
    <servlet-name>spring</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>spring</servlet-name>
    <url-pattern>/</url-pattern>
</servlet-mapping>

【问题讨论】:

  • 是什么让你认为org.springframework.core.ResolvableTypeProvider 在你的类路径中?
  • 你做了什么导致这个输出?您正在创建某些东西的声明还应包含您已采取的步骤,包括您使用的任何相关代码或命令。
  • 发布您的 POM。假设依赖项设置错误。
  • @DarrenForsythe 我已经发布了 pom.xml 和 web.xml
  • 欢迎来到 Stack Overflow!在尝试提出更多问题之前,请阅读How do I ask a good question?

标签: java maven tomcat


【解决方案1】:

您正在混合各种版本的 spring 依赖项,除非您有特殊原因,否则您不应该这样做。

请参阅这篇博文,详细说明如何以及为什么不应该这样做,它与 Spring Boot 相关,但想法完全相同 https://spring.io/blog/2016/04/13/overriding-dependency-versions-with-spring-boot

此处显示的快速示例,http://www.baeldung.com/spring-maven-bom

<dependencyManagement>

<dependency>
   <groupId>org.springframework</groupId>
   <artifactId>spring-framework-bom</artifactId>
   <version>4.3.12.RELEASE</version>
   <type>pom</type>
   <scope>import</scope>
</dependency>

</dependencyManagement>
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-webmvc</artifactId>
</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>
</dependency>
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-context</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework/spring-tx -->
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-tx</artifactId>
</dependency>

<!-- https://mvnrepository.com/artifact/org.springframework/spring-beans -->
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-beans</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-jdbc</artifactId>
</dependency>
<dependency>
    <groupId>log4j</groupId>
    <artifactId>log4j</artifactId>
    <version>1.2.17</version>
</dependency>

依赖关系通过 BOM 导入来控制。此外,我相信您定义的很多内容都会被传递,例如不需要定义contextbeans 等。我会检查您的依赖层次结构并展平定义的依赖关系。

【讨论】:

  • 为什么投反对票?由于格式化也错过了其他依赖项,但你明白了。
猜你喜欢
  • 2023-01-22
  • 2022-09-30
  • 2016-02-11
  • 2016-12-28
  • 2022-11-26
  • 2022-10-07
  • 2011-05-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多