编译错误“需要的库文件不能读取”- Spring工具套件。

时间:2023-01-25 14:33:36

I am starting to configure my development environment and I am using Spring Tool Suite 2.8.1 along with m2E 1.01.

我开始配置我的开发环境,我使用的是Spring Tool Suite 2.8.1和m2e1.01。

As far as I can tell, since this is a Maven Project (my first), my Maven POM is dictating (along with m2E smarts) my project build configuration and dependencies.

据我所知,由于这是一个Maven项目(我的第一个项目),我的Maven POM正在(与m2E smarts一起)命令我的项目构建配置和依赖项。

What I would like to know is why my IDE is displaying Java Build Problems that read "Archive required for library library/path/somejar.jar cannot be read or is not a valid zip file" when I can see the jars in my .m2 repository?

我想知道的是,为什么我的IDE显示了Java构建问题,这些问题读取了“库库/路径/somejar所需的归档文件”。jar不能读取或不是有效的zip文件“当我可以看到我的。m2存储库中的jar文件时?”

All the errors pertained to commons-logging:1.1.1 which I excluded in my parent-pom. This was a transistive dependancy via spring-context-support:3.0.5. I excluded that library from my build and now the errors pertain to the spring-context-support library..

所有的错误都与公共日志记录有关:1.1.1我将其排除在我的父-pom中。通过spring上下文支持,这是一个过渡依赖关系:3.0.5。我把那个库从我的构建中排除了,现在错误属于spring上下文支持库。

I have attached a screenshot to illustrate.

我附上了一个截图来说明。

编译错误“需要的库文件不能读取”- Spring工具套件。

Many thanks

非常感谢

14 个解决方案

#1


68  

Indeed IDEs often cache the local repository (Eclipse does something similar, and I have to relaunch Eclipse).

实际上,ide经常缓存本地存储库(Eclipse也做了类似的事情,我必须重新启动Eclipse)。

One ugly maven behavior you might encounter is that if you declare a dependency before you actually install it, maven will create an empty version of the missing dependency (folder with metadata but no jar), and you will have to manually clean your .m2 repository.

您可能会遇到的一个丑陋的maven行为是,如果您在实际安装之前声明了一个依赖项,maven将创建一个空版本的缺失依赖项(带有元数据的文件夹,但没有jar),您将不得不手动清理您的.m2存储库。

Third, an installed archive (jar...) can get corrupted, so try to open it with any archive tool (7zip...) to test it, and delete the whole folder if the archive is corrupted.

第三,一个已安装的存档(jar…)可能会被损坏,所以尝试用任何存档工具(7zip…)打开它来测试它,如果归档文件损坏了,就删除整个文件夹。

#2


9  

In my case I had to manually delete all the files in .m2\repository folder and then open command prompt and run mvn -install command in my project directory.

在我的例子中,我必须手动删除.m2\repository文件夹中的所有文件,然后在我的项目目录中打开命令提示符并运行mvn -install命令。

#3


7  

I was using Eclipse as IDE and I was getting very same error. I had to do Project->Maven->Update Project. Select all the checkboxes below except "offline" esp. the one "Force update of snapshots/releases" and click OK. Did the Clean Build for the Project again.

我使用的是Eclipse作为IDE,而我的错误是一样的。我必须做Project->Maven->更新项目。选择下面的所有复选框,除了“离线”,即“强制更新快照/发布”,然后单击“确定”。为项目重新构建了。

#4


1  

In my case I tried all the tips suggested but the error remained. I solved changing with a more recent version and writing that in the pom.xml. After this everything is now ok.

在我的案例中,我尝试了所有建议,但错误仍然存在。我用一个更近的版本解决了更改,并将其写入了pom.xml。在这之后一切都好了。

#5


1  

For Googlers:

员工:

In my case I had accidentally manually added a Java class to the build path while poking around Eclipse. By taking a look at the 'Configure Build Path...> Libraries I removed the culprit class and now only have the

在我的例子中,我意外地手动添加了一个Java类到构建路径中,同时在Eclipse中进行查找。通过查看“配置构建路径…”>库我删除了罪犯类,现在只有。

  • JRE System Library
  • JRE系统库
  • Maven Dependencies
  • Maven的依赖关系

and nothing is complaining.

并没有抱怨。

#6


1  

Delete corrupted files from your local .m2 repository and Ctrl+F5 (Update Maven Project) in Eclipse/STS. It'll download and install these files.

在Eclipse/STS中删除来自本地.m2存储库和Ctrl+F5(更新Maven项目)的损坏文件。它将下载并安装这些文件。

#7


0  

This could be due to you have added spring-licence.txt file to your web app libraries.

这可能是由于你增加了弹簧许可证。txt文件到你的web应用程序库。

I had similar issue and resolved after removing that text file. in libraries it will expect jar file only.

在删除该文本文件后,我有类似的问题并解决了。在库中,它只需要jar文件。

Thanks, Channa.

谢谢,鲤鱼。

#8


0  

I deleted the local maven repository. Then just rightclick the project -> Maven -> Update Project... Select all concerned projects and click OK.

我删除了本地maven存储库。然后右击项目-> Maven ->更新项目…选择所有相关项目并单击OK。

#9


0  

Remove maven dependenices from build path

从构建路径删除maven依赖项。

#10


0  

I faced this problem. I had "Archive for required library spring-boot-devtools cannot be read or is not a valid ZIP file" and the solution was like that:- 1- determine the dependencies names that have problems(for may case it is spring-boot-devtools). 2- close eclipse. 3- search in your .m2 file on these dependencies(by name). 4- delete these folders. 5- reopen eclipse and let maven rebuild your dependencies again.

我面临这个问题。我有“对需要的库进行归档,但不能读取或不是有效的ZIP文件”,解决方案是这样的:- 1——确定有问题的依赖项名称(可能是spring-boot-devtools)。2 -关闭eclipse。在您的.m2文件中搜索这些依赖项(按名称)。4 -删除这些文件夹。5-重新打开eclipse,让maven重新构建您的依赖项。

#11


0  

Ok, I had the same problem with STS on a mac and solved it by deleting all the files in repository folder and from the STS IDE click on the project and then Maven -> Update project. Give it a couple of minutes to download all the dependencies and the problem is solved.

好的,我在mac上遇到了同样的问题,通过删除存储库文件夹中的所有文件,以及从STS IDE点击项目和Maven ->更新项目来解决它。给它几分钟的时间下载所有的依赖关系,问题就解决了。

#12


0  

I face with the same issue. I deleted the local repository and relaunched the ID. It worked fine .

我面临着同样的问题。我删除了本地存储库并重新启动了ID。

#13


0  

Just had this problem on Indigo SR2. It popped up after I removed a superfluous jar from the classpath (build path). Restarting Eclipse didn't help. Added back the jar to the build path...error went away. Removed the jar once again, and this time I was spared from another complaint.

在Indigo SR2上有这个问题。在我从类路径(构建路径)中删除了一个多余的jar之后,它就出现了。重新启动Eclipse并没有帮助。将jar添加到构建路径…错误就走了。又一次把罐子拿走了,这次我没再抱怨了。

#14


0  

none of the solutions above helped my problem. I've resolved it by deleting all files in {projectworkspace}/.metadata folder AND in {location}/.m2 folder and let eclipse download every single thing again. Hope this helps someone, cheers!

以上的解决方案都没有帮助我解决问题。我已经通过删除{projectworkspace}/的所有文件来解决它。元数据文件夹和{location}/。m2文件夹,让eclipse再次下载每一件东西。希望这对某人有帮助,干杯!

#1


68  

Indeed IDEs often cache the local repository (Eclipse does something similar, and I have to relaunch Eclipse).

实际上,ide经常缓存本地存储库(Eclipse也做了类似的事情,我必须重新启动Eclipse)。

One ugly maven behavior you might encounter is that if you declare a dependency before you actually install it, maven will create an empty version of the missing dependency (folder with metadata but no jar), and you will have to manually clean your .m2 repository.

您可能会遇到的一个丑陋的maven行为是,如果您在实际安装之前声明了一个依赖项,maven将创建一个空版本的缺失依赖项(带有元数据的文件夹,但没有jar),您将不得不手动清理您的.m2存储库。

Third, an installed archive (jar...) can get corrupted, so try to open it with any archive tool (7zip...) to test it, and delete the whole folder if the archive is corrupted.

第三,一个已安装的存档(jar…)可能会被损坏,所以尝试用任何存档工具(7zip…)打开它来测试它,如果归档文件损坏了,就删除整个文件夹。

#2


9  

In my case I had to manually delete all the files in .m2\repository folder and then open command prompt and run mvn -install command in my project directory.

在我的例子中,我必须手动删除.m2\repository文件夹中的所有文件,然后在我的项目目录中打开命令提示符并运行mvn -install命令。

#3


7  

I was using Eclipse as IDE and I was getting very same error. I had to do Project->Maven->Update Project. Select all the checkboxes below except "offline" esp. the one "Force update of snapshots/releases" and click OK. Did the Clean Build for the Project again.

我使用的是Eclipse作为IDE,而我的错误是一样的。我必须做Project->Maven->更新项目。选择下面的所有复选框,除了“离线”,即“强制更新快照/发布”,然后单击“确定”。为项目重新构建了。

#4


1  

In my case I tried all the tips suggested but the error remained. I solved changing with a more recent version and writing that in the pom.xml. After this everything is now ok.

在我的案例中,我尝试了所有建议,但错误仍然存在。我用一个更近的版本解决了更改,并将其写入了pom.xml。在这之后一切都好了。

#5


1  

For Googlers:

员工:

In my case I had accidentally manually added a Java class to the build path while poking around Eclipse. By taking a look at the 'Configure Build Path...> Libraries I removed the culprit class and now only have the

在我的例子中,我意外地手动添加了一个Java类到构建路径中,同时在Eclipse中进行查找。通过查看“配置构建路径…”>库我删除了罪犯类,现在只有。

  • JRE System Library
  • JRE系统库
  • Maven Dependencies
  • Maven的依赖关系

and nothing is complaining.

并没有抱怨。

#6


1  

Delete corrupted files from your local .m2 repository and Ctrl+F5 (Update Maven Project) in Eclipse/STS. It'll download and install these files.

在Eclipse/STS中删除来自本地.m2存储库和Ctrl+F5(更新Maven项目)的损坏文件。它将下载并安装这些文件。

#7


0  

This could be due to you have added spring-licence.txt file to your web app libraries.

这可能是由于你增加了弹簧许可证。txt文件到你的web应用程序库。

I had similar issue and resolved after removing that text file. in libraries it will expect jar file only.

在删除该文本文件后,我有类似的问题并解决了。在库中,它只需要jar文件。

Thanks, Channa.

谢谢,鲤鱼。

#8


0  

I deleted the local maven repository. Then just rightclick the project -> Maven -> Update Project... Select all concerned projects and click OK.

我删除了本地maven存储库。然后右击项目-> Maven ->更新项目…选择所有相关项目并单击OK。

#9


0  

Remove maven dependenices from build path

从构建路径删除maven依赖项。

#10


0  

I faced this problem. I had "Archive for required library spring-boot-devtools cannot be read or is not a valid ZIP file" and the solution was like that:- 1- determine the dependencies names that have problems(for may case it is spring-boot-devtools). 2- close eclipse. 3- search in your .m2 file on these dependencies(by name). 4- delete these folders. 5- reopen eclipse and let maven rebuild your dependencies again.

我面临这个问题。我有“对需要的库进行归档,但不能读取或不是有效的ZIP文件”,解决方案是这样的:- 1——确定有问题的依赖项名称(可能是spring-boot-devtools)。2 -关闭eclipse。在您的.m2文件中搜索这些依赖项(按名称)。4 -删除这些文件夹。5-重新打开eclipse,让maven重新构建您的依赖项。

#11


0  

Ok, I had the same problem with STS on a mac and solved it by deleting all the files in repository folder and from the STS IDE click on the project and then Maven -> Update project. Give it a couple of minutes to download all the dependencies and the problem is solved.

好的,我在mac上遇到了同样的问题,通过删除存储库文件夹中的所有文件,以及从STS IDE点击项目和Maven ->更新项目来解决它。给它几分钟的时间下载所有的依赖关系,问题就解决了。

#12


0  

I face with the same issue. I deleted the local repository and relaunched the ID. It worked fine .

我面临着同样的问题。我删除了本地存储库并重新启动了ID。

#13


0  

Just had this problem on Indigo SR2. It popped up after I removed a superfluous jar from the classpath (build path). Restarting Eclipse didn't help. Added back the jar to the build path...error went away. Removed the jar once again, and this time I was spared from another complaint.

在Indigo SR2上有这个问题。在我从类路径(构建路径)中删除了一个多余的jar之后,它就出现了。重新启动Eclipse并没有帮助。将jar添加到构建路径…错误就走了。又一次把罐子拿走了,这次我没再抱怨了。

#14


0  

none of the solutions above helped my problem. I've resolved it by deleting all files in {projectworkspace}/.metadata folder AND in {location}/.m2 folder and let eclipse download every single thing again. Hope this helps someone, cheers!

以上的解决方案都没有帮助我解决问题。我已经通过删除{projectworkspace}/的所有文件来解决它。元数据文件夹和{location}/。m2文件夹,让eclipse再次下载每一件东西。希望这对某人有帮助,干杯!