java - Spring 和 Hibernate 依赖项没有得到解决
问题描述
对于所有导入的包,我都收到此错误消息“导入组织.....无法解析”。并且我的 Spring 和 Hibernate 依赖项没有得到解决。我尝试了多种解决方案来解决此错误,但没有任何接缝可以工作,以下是我尝试过的解决方案。
- Maven => 更新项目但同样的错误。也做了 => 强制更新快照/发布
- 我还尝试右键单击项目并选择属性,然后选择 Maven。取消选中标记为“解决工作区项目中的依赖项”的框,点击应用,然后点击确定
- 删除了我的本地 Maven 存储库、.m2 目录和重新启动的 Eclipse。
https://i.stack.imgur.com/LCUta.png
'''
<modelVersion>4.0.0</modelVersion>
<groupId>com.luv2code.springdemo</groupId>
<artifactId>spring-crm-rest</artifactId>
<version>1.0.0</version>
<packaging>war</packaging>
<properties>
<springframework.version>5.0.6.RELEASE</springframework.version>
<hibernate.version>5.4.1.Final</hibernate.version>
<mysql.connector.version>5.1.45</mysql.connector.version>
<c3po.version>0.9.5.2</c3po.version>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
<!-- Spring -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>${springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>${springframework.version}</version>
</dependency>
<!-- Add Jackson for JSON converters -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.9.5</version>
</dependency>
<!-- Hibernate -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>${hibernate.version}</version>
</dependency>
<!-- MySQL -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${mysql.connector.version}</version>
</dependency>
<!-- C3PO -->
<dependency>
<groupId>com.mchange</groupId>
<artifactId>c3p0</artifactId>
<version>${c3po.version}</version>
</dependency>
<!-- Servlet+JSP+JSTL -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>javax.servlet.jsp-api</artifactId>
<version>2.3.1</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<!-- to compensate for java 9 not including jaxb -->
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.0</version>
</dependency>
</dependencies>
<build>
<finalName>spring-crm-rest</finalName>
<plugins>
<!-- Builds a Web Application Archive (WAR) file from the project output
and its dependencies. -->
<plugin>
<!-- Add Maven coordinates (GAV) for: maven-war-plugin -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.0</version>
</plugin>
</plugins>
</build>
'''
解决方案
作为第一步,您需要从项目根目录中的终端运行mvn clean install
命令。通过这种方式,您将“将包安装到本地存储库中,以用作依赖项”。之后,您肯定需要刷新工作区并运行 mvn update
推荐阅读
- search - ArangoSearch:如何在不指定文档字段的情况下进行搜索?
- elasticsearch - 将具有动态映射值的字段添加到所有文档
- php - 发送邮件时在视图文件中显示数据
- javascript - NodeJS 错误“不能在模块外使用 import 语句”
- c# - 没有适用于 MVC 3 的 Sustainsys.Saml2?有没有其他选择?
- graph - 图数据库中的建模时间
- python - 这些功能是如何实现的?
- powershell - Powershell远程:具有嵌套函数的函数
- java - 为什么 apache http 客户端比 java 中的 URL.openConnection 慢 2 倍?
- mysql - 如何在存在时选择列的值