Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to solve the problem that import package Times Java package does not exist

2025-01-16 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 that the import package Times Java package does not exist", 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 that the import package Times Java package does not exist" this article.

There are many solutions on the Internet, and all I can think of are put together to facilitate future inspection. You may be able to solve the problem by using one of them. I used the last one to solve the problem.

If the package you want to import does not exist in Libraries all the time, you have to see if there is any problem with the corresponding dependency in pom, and whether there is a corresponding jar package in the warehouse where the name version is used. If you are sure there is no problem, then try to solve it in the first few ways below.

1. Execute Maven-> reload project

Purpose: re-import the Maven package

There are 2 ways:

1. Select Project directory right-> Maven-> reload project

Refresh 2.maven plug-in (recommended)

two。 Execute Invalidate and Restart

Function: clear the Idea cache and restart Idea.

In many cases, the problems caused by idea can be basically solved in this way.

Method:-> Toolbar-> File-> Invalidate Caches / Restart

3. Unified coding

Function: set the encoding to UTF-8.

Method: set it to UTF-8. Don't forget to click Apply after setting it.

4. Recompile

There are many ways:

1. Click rebuild under the Build menu

two。 Under the corresponding project / module under the maven plug-in, click 1Pol 2. Install represents a reinstall package.

5. Set idea to automatically load jar packages

When there is an error as shown in the title, don't worry, this is because there is an error in configuring the package for Java, and you may not have set up for IDEA to load the Jar package automatically. The solution is as follows:

File- > Setting- > Build,Execution,Deployment- > Maven- > Importing

6. After deleting the local private repository, update maven and reload

Ps: the problems I encountered were not solved in any of the above ways. I used the next ones to solve them. I hope you don't need to see this.

8. If the above methods are not solved, there is no doubt that it is the problem of idea. If you are using version 2020.1'3, there is a greater chance that there will be a problem.

Solution: if the build/run action of IDEA is delegated to maven

At this point and then recompile and run, it can pass normally.

However, if you feel that the startup is slow, you need to check whether it has been compiled twice, you can write a test class, insert a piece of data as soon as the compilation starts, and see if the database has two; you can also look directly at the compilation box under idea.

Why is it compiled twice?

After the above delegation is checked by maven, the problem of not finding the package is solved, but it is possible that the maven plug-in and idea will be compiled one after another.

Solution: replace the compiled plug-ins in pom.xml with

Org.apache.maven.plugins maven-surefire-plugin 2.22.1 true

At this point, I found that I could only compile once. There will be no problem starting the project locally through idea.

However, when you package the project and start it through jar, there may be an error and you can't find the main attribute. Of course, it's not better. If so, just continue to add the following code.

Org.apache.maven.plugins maven-compiler-plugin 1.81.8 org.springframework.boot spring-boot-maven-plugin repackage above is "how to solve the problem that the import package Times Java package does not exist All the contents of this article 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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report