repositories { maven{ url 'https://maven.aliyun.com/nexus/content/groups/public/'} maven{ url 'https://maven.aliyun.com/nexus/content/repositories/jcenter'} mavenCentral() maven { url "https://repo.spring.io/libs-spring-framework-build" } }编译工作 按照官网的方式编译: 使用gradlew(gradle-wrapper命令) 先编译oxm:compileTest Java: Precompile spring-oxm with ./gradlew :spring-oxm:compileTestJava 1.将id=4那行进行注释 2.编译compileTestJava模块 打开源码所在文件夹,在windows cmd命令中输入,在windows中当前目录无需输入“./”。
gradlew :spring-oxm:compileTestJava配置了镜像很快(一两分钟)就能编译完成, 如果要很久说明你的镜像没起作用,如果编译异常请自行百度,每个人的电脑及环境产生的异常都有可能。
编写代码测试ioc功能
dependencies { testCompile group: 'junit', name: 'junit', version: '4.12' compile(project(":spring-context")) }
package cn.tulingxueyuan.beans; import org.springframework.stereotype.Service; /*** * @Author 徐庶 QQ:1092002729 * @Slogan 致敬大师,致敬未来的你 */ @Service public class UserServiceImpl { public void sayHi(){ System.out.println("Hello Spring!"); } }
import cn.tulingxueyuan.beans.UserServiceImpl; import javafx.application.Application; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; /*** * @Author 徐庶 QQ:1092002729 * @Slogan 致敬大师,致敬未来的你 */ @Configuration @ComponentScan("cn.tulingxueyuan") public class MainStat { public static void main(String[] args) { ApplicationContext context=new AnnotationConfigApplicationContext(MainStat.class); UserServiceImpl bean = context.getBean(UserServiceImpl.class); bean.sayHi(); } }