我实现了一个spring和hibernate项目。但是我没有在我的pom.xml文件中包含spring核心。但是我的代码正在工作,依赖注入也可以工作。
我的怀疑是
下面是我的依赖项(pom.xml)
<dependencies>
<!-- Spring MVC Dependency -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>
<!-- Spring ORM -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>${spring.version}</version>
</dependency>
<!-- Hibernate Core -->
<!-- Hibernate Validator -->
<!-- JSTL Dependency -->
<!-- Servlet Dependency -->
<!-- JSP Dependency -->
</dependencies>发布于 2019-03-22 09:32:50
spring和spring都依赖于spring核心,因此您不必显式地添加此依赖项。您可以在这里检查spring的所有依赖项:https://github.com/spring-projects/spring-framework/blob/master/spring-webmvc/spring-webmvc.gradle。
以及这里的spring-orm依赖项:https://github.com/spring-projects/spring-framework/blob/master/spring-orm/spring-orm.gradle
此外,您还可以使用mvn dependency:tree命令检查所有依赖项,而无需查看源代码。
发布于 2019-03-22 09:33:19
spring-webmvc以及spring-orm (以及几乎所有其他spring-XYZ模块)都依赖于spring-core,因此它是作为传递依赖项加载的。请参阅这里的所有依赖项:https://mvnrepository.com/artifact/org.springframework/spring-webmvc/5.1.5.RELEASE
https://stackoverflow.com/questions/55296505
复制相似问题