eclipse spring 工具套件 spring mvc 项目 - 创建后的 22 个问题

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14761234/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 19:57:46  来源:igfitidea点击:

spring tool suite spring mvc project - 22 problems right after creating

eclipsemavenspring-mvceclipse-plugin

提问by Skeeve

So, I downloaded and installed STS and then I've created a new Spring MVC Project. Right after that sts alert me about 22 problems, here they are:

所以,我下载并安装了 STS,然后我创建了一个新的 Spring MVC 项目。紧接着,sts 提醒我关于 22 个问题,它们是:

Description Resource    Path    Location    Type
Missing artifact aopalliance:aopalliance:jar:1.0    pom.xml /ContactManager line 1          Maven Dependency Problem
Missing artifact org.springframework:spring-beans:jar:3.1.1.RELEASE pom.xml /ContactManager line 1  Maven Dependency Problem
Missing artifact org.springframework:spring-context:jar:3.1.1.RELEASE   pom.xml /ContactManager line 1  Maven Dependency Problem
Missing artifact org.springframework:spring-aop:jar:3.1.1.RELEASE   pom.xml /ContactManager line 1  Maven Dependency Problem
ArtifactDescriptorException: Failed to read artifact descriptor for org.slf4j:slf4j-api:jar:1.6.6: ArtifactResolutionException: Failure to transfer org.slf4j:slf4j-api:pom:1.6.6 from http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced. Original error: Could not transfer artifact org.slf4j:slf4j-api:pom:1.6.6 from/to central (http://repo.maven.apache.org/maven2): C:\Users\Skeeve\.m2\repository\org\slf4j\slf4j-api.6.6\slf4j-api-1.6.6.pom.ahc3656264e3b414ddf (Не удается найти указанный файл)   pom.xml /ContactManager line 1  Maven Dependency Problem
Missing artifact org.slf4j:jcl-over-slf4j:jar:1.6.6 pom.xml /ContactManager line 1  Maven Dependency Problem
Missing artifact org.aspectj:aspectjrt:jar:1.6.10   pom.xml /ContactManager line 1  Maven Dependency Problem
Missing artifact org.springframework:spring-web:jar:3.1.1.RELEASE   pom.xml /ContactManager line 1  Maven Dependency Problem
Missing artifact org.springframework:spring-context-support:jar:3.1.1.RELEASE   pom.xml /ContactManager line 1  Maven Dependency Problem
Missing artifact org.springframework:spring-webmvc:jar:3.1.1.RELEASE    pom.xml /ContactManager line 1  Maven Dependency Problem
Missing artifact org.springframework:spring-asm:jar:3.1.1.RELEASE   pom.xml /ContactManager line 1  Maven Dependency Problem
Missing artifact org.springframework:spring-expression:jar:3.1.1.RELEASE    pom.xml /ContactManager line 1  Maven Dependency Problem
Missing artifact org.springframework:spring-core:jar:3.1.1.RELEASE  pom.xml /ContactManager line 1  Maven Dependency Problem
Missing artifact junit:junit:jar:4.7    pom.xml /ContactManager line 1  Maven Dependency Problem
Missing artifact javax.servlet:jstl:jar:1.2 pom.xml /ContactManager line 1  Maven Dependency Problem
Missing artifact javax.servlet.jsp:jsp-api:jar:2.1  pom.xml /ContactManager line 1  Maven Dependency Problem
Missing artifact javax.servlet:servlet-api:jar:2.5  pom.xml /ContactManager line 1  Maven Dependency Problem
Missing artifact javax.inject:javax.inject:jar:1    pom.xml /ContactManager line 1  Maven Dependency Problem
Missing artifact log4j:log4j:jar:1.2.15 pom.xml /ContactManager line 1  Maven Dependency Problem
Missing artifact org.slf4j:slf4j-log4j12:jar:1.6.6  pom.xml /ContactManager line 1  Maven Dependency Problem

Description Resource    Path    Location    Type
The project cannot be built until build path errors are resolved    ContactManager      Unknown Java Problem

Description Resource    Path    Location    Type
The container 'Maven Dependencies' references non existing library 'C:\Users\Skeeve\.m2\repository\org\springframework\spring-context.1.1.RELEASE\spring-context-3.1.1.RELEASE.jar'   ContactManager      Build path  Build Path Problem

How can I solve that problem? Thank you

我该如何解决这个问题?谢谢

回答by jocki

I've also encountered a lot of error when creating a new STS project for the first time. This seems to be happen only if I don't have any Maven repository or haven't launch/use Maven before. In my case, I solve this by launching Maven command from command line manually. Try to 'cd' to the project directory that contains pom.xmland call mvnthat comes with STS from there.

第一次新建STS项目的时候也遇到了很多错误。这似乎只有在我没有任何 Maven 存储库或之前没有启动/使用 Maven 时才会发生。就我而言,我通过从命令行手动启动 Maven 命令来解决这个问题。尝试“cd”到包含STS 并从那里pom.xml调用的项目目录mvn

   cd c:\users\name\sts-projects\projectname
   c:\programs\springsource\apache-maven-3.0.3\bin\mvn compile

Then, open STS, right click on project name, select 'Maven', 'Update Project...' Select on 'Force Update of Snapshots/Releases'. Don't select 'Offline'.

然后,打开 STS,右键单击项目名称,选择“Maven”、“更新项目...” 选择“强制更新快照/发布”。不要选择“离线”。

回答by Jan Petzold

Are you behind a proxy? If so, you need to configure Maven to use it.

你在代理后面吗?如果是这样,您需要配置 Maven 才能使用它。

If that is not the case just right-click on your project and select Maven->Update Project Configuration. This should work. Probably you have to clean/refresh the project.

如果不是这种情况,只需右键单击您的项目并选择Maven->Update Project Configuration。这应该有效。可能您必须清理/刷新项目。