首页 文章

我'm creating a maven project and I'是一个初学者..我收到了这个错误 . 可以帮助解决这个问题是我的pom.xml和web.xml [重复]

提问于
浏览
-2

这个问题在这里已有答案:

http://maven.apache.org/maven-v4_0_0.xsd“> 4.0.0 com.project Online_Medical_Reporting_System war 0.0.1-SNAPSHOT Online_Medical_Reporting_System Maven Webapp http://maven.apache.org junit junit 3.8.1 test org.hibernate.javax.persistence hibernate-jpa -2.1-api 1.0.0.Final org.hibernate hibernate-validator 4.0.2.GA org.hibernate hibernate-core 3.3.2.GA org.springframework spring-aop 4.1.6.RELEASE

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

Blockquote

http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd“id =”WebApp_ID“version =”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>

1 回答

  • -1

    你混合了Spring依赖项的版本,除非你有特殊的原因,否则你永远不应该这样做 .

    请参阅这篇博文,详细介绍了如何以及为什么你不应该't do this, it'的 Spring 季靴子相关但这个想法完全相同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 等 . 我会检查您的依赖关系层次结构并展平已定义的依赖关系 .

相关问题