spring导入Idea

spring导入IDEA

基础环境
  •      spring 5.3.x
  •      JDK 1.8
  •      Gradle 7.5

gradle -version 命令查看gradle版本;
java -version jdk版本信息

代码准备

从github上下载spring代码,切换分支到 5.3.x版本
查看import-into-idea.md文件内容,执行gradlew spring-oxm:compileTestJava 执行完成后可将代码导入到Idea

代码导入Idea

idea -> File -> Open 打开spring代码文件夹,导入到Idea

修改Idea-gradle配置

修改IDEA-gradle配置为1.8jdk

在spring代码中新增自己的module

打开Idea Project Structure
在spring中新增module

修改自己module的 gradle文件配置
项目gradle配置

plugins {
    id 'java-library'
}

group 'org.springframework'
version '5.3.24-SNAPSHOT'

repositories {
    mavenCentral()
}

dependencies {
    api(project(":spring-aop"))
    api(project(":spring-beans"))
    api(project(":spring-context"))
    api(project(":spring-core"))
    api(project(":spring-expression"))
    testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.2'
    testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.7.2'
}

test {
    useJUnitPlatform()
}

注意plugins id 配置为 java-library#

测试代码

测试代码
SimpleBean.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	   xsi:schemaLocation="http://www.springframework.org/schema/beans
                        http://www.springframework.org/schema/beans/spring-beans.xsd">
	<bean class="com.jingu.study.SimpleBean"/>
</beans>

SimpleBeanSpring.java

public class SimpleBeanSpring {
	public static void main(String[] args) {
		ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("SimpleBean.xml");
		SimpleBean bean = context.getBean(SimpleBean.class);
		bean.send();
		context.close();
	}
}

SimpleBean.java

public class SimpleBean {
	public void send() {
		System.out.println("I am send method from SimpleBean!");
	}
}

测试结果

测试结果

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值