Eclipse 使用从源代码构建的spring依赖项创建maven项目

Eclipse 使用从源代码构建的spring依赖项创建maven项目,eclipse,spring,maven,Eclipse,Spring,Maven,我想研究springframework的实现。所以我跟着林克: 通过这个链接,我能够构建各种spring模块,并成功地将这些项目导入到我的eclipse工作区中。 为了验证代码,我在导入spring框架项目的同一Eclipse工作区中创建了一个基于maven的spring MVC项目。我将spring项目作为构建路径依赖项添加到MVC项目中。但是当我为MVC项目执行(clean install-e)pom.xml时,我从代码中引用的所有springframework都显示了编译问题,如包不存在

我想研究springframework的实现。所以我跟着林克:

通过这个链接,我能够构建各种spring模块,并成功地将这些项目导入到我的eclipse工作区中。 为了验证代码,我在导入spring框架项目的同一Eclipse工作区中创建了一个基于maven的spring MVC项目。我将spring项目作为构建路径依赖项添加到MVC项目中。但是当我为MVC项目执行(clean install-e)pom.xml时,我从代码中引用的所有springframework都显示了编译问题,如包不存在、未找到符号等。下面是我的简单java代码:

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

@Controller
public class Home {

    String message = "Welcome to your 1st Maven Spring project !";  

    @RequestMapping("/hello")  
    public ModelAndView showMessage() {  
        System.out.println("from controller");  
        return new ModelAndView("hello", "message", message);  
    }  

}
原因可能是什么

<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.manish.springrestful</groupId>
<artifactId>SpringRestful</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>SpringRestful Maven Webapp</name>
<url>http://maven.apache.org</url>

<dependencies>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>3.8.1</version>
        <scope>test</scope>
    </dependency>
</dependencies>
<build>
    <finalName>SpringRestful</finalName>
    <plugins>
        <plugin>
            <groupId>org.apache.tomcat.maven</groupId>
            <artifactId>tomcat8-maven-plugin</artifactId>
            <version>2.1</version>
            <configuration>
                <url>http://localhost:8080/manager/text</url>
                <server>my-tomcat</server>
                <path>/SpringRestful</path>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.0</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
    </plugins>
</build>

4.0.0
com.manish.springrestful
春意盎然
战争
0.0.1-快照
springrestfulmaven Webapp
http://maven.apache.org
朱尼特
朱尼特
3.8.1
测试
春意盎然
org.apache.tomcat.maven
tomcat8 maven插件
2.1
http://localhost:8080/manager/text
我的雄猫
/春意盎然
org.apache.maven.plugins
maven编译器插件
3
1.8
1.8

添加所需的maven Spring框架依赖项(来自maven存储库)在您的
pom.xml
中,而不是在项目的生成路径中配置它。

您可以显示项目的
pom.xml
吗?尝试将spring依赖项添加到pom.xml中,而不是作为生成路径依赖项。springframework源是一个渐变项目,您正在将其添加到maven的生成路径依赖项中谢谢你的提示。它现在可以编译了。但是我现在如何调试springframework源代码呢?在您的项目中,转到maven->下载源代码。之后,您可以在Springframework代码本身中放置断点。