在springframe work项目的代码拉下来到了本地之后,创建一个test demo,具体代码如下:
import org.spring.*;
public class DemoTest {
public static void main(String[] args) {
ApplicationContext context = new ApplicationContext("applicationContext.xml");
User user = context.getBean("user", User.class);
System.out.println(user);
}
}
其中定义了gradle的build文件如下:
dependencies {
compile(project(":spring-aop"))
compile(project(":spring-beans"))
compile(project(":spring-context"))
compile(project(":spring-core"))
compile(project(":spring-expression"))
}
test {
useJUnitPlatform()
}
另外User类如下定义:
package demo1;
public class User {
private String userName;
private Integer age;
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public Integer getAge() {
return age;
}
public void setAge(Integer age) {
this.age = age;
}
}
发现一个问题:spring的包是导入不了的,具体情况如下图:
最后查找资料得知需要重新创建lib包才行,因此记录一下这个问题。