In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly shows you "how to solve the problem of SpringBoot testing stuck in Resolving Maven dependencies", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "how to solve the problem of SpringBoot testing stuck in Resolving Maven dependencies" this article.
Stuck in Resolving Maven dependencies during the test.
Did you encounter this problem during the test?
Stuck in Resolving Maven dependencies all the time.
In fact, the box is stuck because I have been downloading a jar package that Junit5 depends on, so I can't download it.
At this point, you need to manually import two dependencies in pom
Org.junit.platform junit-platform-launcher test junit junit test
OK, perfect solution!
Lack of Maven Dependencies in Maven project A maven project was built today
After introducing the dependency in the pom.xml file, it is found that there is no Maven Dependencies file in the project structure (below), but the Maven Dependencies file can be found in the java Build Path (as shown below):
However, the dependent jar package added in the pom.xml file will not be automatically downloaded to the project, and so is update Project, so I looked for a lot of methods on the Internet, but found that it was useless after trying. Finally, I looked at my pom.xml file and found that I wrote this tag before the dependency (below). After looking up the information, I found that the function of this tag is only to declare the dependency, not to realize the introduction of the dependency. Therefore, there is no introduction of the jar package. The maven project does not display the Maven Dependencies file.
After removing this tag, the problem is resolved and the maven Dependencies file appears in the maven project.
Other methods to solve the missing Maven Dependencies files on the Internet
Type 1: Maven support is not turned on:
In this case, the Maven that comes with Eclipse or the self-installed Maven does not open the service.
Solution: right-click Maven project-- > Maven-- > Enable Dependency Management
(there may be some maven versions that do not have the option of Enable Dependency Management)
Type 2: classpath file problem or .project file problem:
Solution:
(1) add the following code to the .classpath file:
(2) add the following line to the .project file:
Org.eclipse.m2e.core.maven2Nature
Org.eclipse.jem.workbench.JavaEMFNature org.eclipse.wst.common.modulecore.ModuleCoreNature org.eclipse.jdt.core.javanature org.eclipse.m2e.core.maven2Nature org.eclipse.wst.common.project.facet.core.nature org.eclipse.wst.jsdt.core.jsNature
Category 3: project-- > properties-- > Deployment Assembly-- > Add-- > java build path Entries-- > Maven Dependencies--Finish
Type 4: projects are non-maven projects (in rare cases)
Solution: right-click the project-- > configure-- > Convert to Maven Project
The difference between dependencyManagement and dependencies
The main reason for the previous problem is that the difference between dependencyManagement and dependencies is not clear, so this section mainly summarizes the difference between the two tags in the pom.xml file:
1. Application scenarios of DepencyManagement:
When we have a large number of project modules, it is very convenient for us to use Maven to manage the project, helping us to manage the methods of building, documentation, reporting, dependency, scms, publishing, and distribution. You can easily compile code, manage dependencies, manage binary libraries, and so on.
Because we have so many modules, we abstracted another layer and extracted an itoo-base-parent to manage the common dependencies of the subprojects. In order for the project to run correctly, all subprojects must use a unified version of dependencies, and the dependencies and versions of each project must be consistent to ensure that the results tested and released are the same.
In the POM file at the top of our project, we will see the dependencyManagement element. Manage the version of the jar package through its element, allowing the subproject to refer to a dependent column that does not need to be displayed. Maven moves up the parent-child level until it finds a project with a dependencyManagement element, and then it uses the version number specified in the dependencyManagement element.
Let's take a look at the application in our project: pom inheritance diagram:
Itoo-base-parent (pom.xml)
Org.eclipse.persistence org.eclipse.persistence.jpa ${org.eclipse.persistence.jpa.version} provided Javax javaee-api ${javaee-api.version}
Itoo-base (pom.xml)
Itoo-base-parent com.tgb 0.0.1-SNAPSHOT.. / itoo-base-parent/pom.xml 4.0.0 itoo-base ejb Javax javaee-api com.fasterxml.jackson.core jackson-annotations org.eclipse.persistence Org.eclipse.persistence.jpa provided
The benefit of this: uniformly manage the version number of the project, ensure that the dependencies and versions of each project of the application are consistent, to ensure that the test and release are the same results, therefore, define a common dependency in the top-level pom. At the same time, you can avoid declaring a version number in each child project, so that when you want to upgrade or switch to another version, you only need to update it in the parent container without any modification of a child project; if a child project needs another version number, you only need to declare a version number in dependencies. The subclass uses the version number declared by the subclass and does not inherit from the parent version number.
2 、 Dependencies:
As opposed to dependencyManagement, all dependencies declared in dependencies are automatically introduced and inherited by default by all subprojects.
3. Difference:
(1) dependencies: automatically introduces all dependencies declared in dependencies and inherits by default by all subprojects. If dependencies are not written in the project, the dependencies declared in the parent project dependencies are inherited from the parent project (all properties inherit).
(2) dependencyManagement: this tag only declares dependencies and does not implement introduction, so subprojects need to show the required dependencies for the declaration. If the dependency is not declared in the child project, it will not be inherited from the parent project; only if the dependency is written in the child project and no specific version is specified, it will be inherited from the parent project, and both version and scope are read from the parent pom;. In addition, if the version number is specified in the child project, the jar version specified in the child project will be used.
(3) dependencies in dependencyManagement does not affect project dependencies; independent dependencies elements affect project dependencies. The dependencies element in dependencyManagement works only if the version information is not specified in the outer dependencies element. One is the project dependency, and the other is the dependency management control when the maven project is multi-module.
The above is all the contents of this article entitled "how to solve the problem of getting stuck in Resolving Maven dependencies during SpringBoot testing". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.