sha*_*Hwk 5 java spring spring-mvc maven
我收到The import org.springframework cannot be resolved
所有进口商品的错误信息。我的 POM.XML 如下:我确信我已经包含了所有必要的依赖项。不知道为什么会这样。帮助
POM文件
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.app.controller</groupId>
<artifactId>FirstController</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<name>webapp spring</name>
<url>http://maven.apache.org</url>
<properties>
<spring.version>4.0.0.RELEASE</spring.version>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<!-- Spring 3 dependencies -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>
</dependencies>
<build>
<finalName>FirstController</finalName>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
Run Code Online (Sandbox Code Playgroud)
第一控制器.java
package my.controller;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@Controller
@RequestMapping("/hi")
public class FirstController {
@RequestMapping(method = RequestMethod.GET)
public String printWelcome(ModelMap model) {
model.addAttribute("message", "Spring 3 MVC Hello LA");
return "hello";
}
}
Run Code Online (Sandbox Code Playgroud)
检查 的输出mvn clean install
。并查看相关 jar 是否正在下载。查看$HOME/.m2/repo/....
它是否确实存在。
在 IDE 中,确保您已正确配置构建路径(例如在 eclipse 中,右键单击项目,构建路径,第三个选项卡)
此外,我想它应该是pom.xml
(小写) 而不是POM.XML
,因为我相信大小写很重要。但我猜你是在不知情的情况下把它放在帖子里的。
归档时间: |
|
查看次数: |
85730 次 |
最近记录: |