1)SpringBoot工程
1.注意:新建SpringBoot工程时,一定要根据你当前的jdk版本选择好SpringBoot的版本,比如:jdk为11,则不能创建3.x的SpringBoot工程,有时候2021版本的idea强制我创建3.x版本的SpringBoot,创建完也报错,简单的改下配置也不管用。
最终则是:在创建3.x工程时,按照提示下载了jdk21之后则正常运行了。
2.test下的单元测试
package com.example.demo;import com.example.demo.pojo.Student;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;@SpringBootTest
class Demo1ApplicationTests {@AutowiredStudent student;@Testvoid contextLoads() {System.out.println(student.getAge());}}
可见,Student之类的类完全是正常工程下的,在这里也是可以Autowired的。
2)普通java工程使用Junit