项目截图
包引用
bean.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 id="user" class="com.xjh.study.User"></bean> </beans>
User.java
package com.xjh.study; public class User { public void add() { System.out.println(" User add()........"); } }
TestSpring5.java
package com.xjh.study; import org.junit.Test; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; import java.util.Date; public class TestSpring5 { @Test public void testAdd() { ApplicationContext context = new ClassPathXmlApplicationContext("bean.xml"); User user = context.getBean("user", User.class); System.out.println(user); user.add(); } }
打印日志输出
C:\Java\jdk1.8.0_321\bin\java.exe -ea -Didea.test.cyclic.buffer.size=1048576 "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2022.2.1\lib\idea_rt.jar=62019:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2022.2.1\bin" -Dfile.encoding=UTF-8 -classpath "C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2022.2.1\lib\idea_rt.jar;C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2022.2.1\plugins\junit\lib\junit5-rt.jar;C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2022.2.1\plugins\junit\lib\junit-rt.jar;C:\Java\jdk1.8.0_321\jre\lib\charsets.jar;C:\Java\jdk1.8.0_321\jre\lib\deploy.jar;C:\Java\jdk1.8.0_321\jre\lib\ext\access-bridge-64.jar;C:\Java\jdk1.8.0_321\jre\lib\ext\cldrdata.jar;C:\Java\jdk1.8.0_321\jre\lib\ext\dnsns.jar;C:\Java\jdk1.8.0_321\jre\lib\ext\jaccess.jar;C:\Java\jdk1.8.0_321\jre\lib\ext\jfxrt.jar;C:\Java\jdk1.8.0_321\jre\lib\ext\localedata.jar;C:\Java\jdk1.8.0_321\jre\lib\ext\nashorn.jar;C:\Java\jdk1.8.0_321\jre\lib\ext\sunec.jar;C:\Java\jdk1.8.0_321\jre\lib\ext\sunjce_provider.jar;C:\Java\jdk1.8.0_321\jre\lib\ext\sunmscapi.jar;C:\Java\jdk1.8.0_321\jre\lib\ext\sunpkcs11.jar;C:\Java\jdk1.8.0_321\jre\lib\ext\zipfs.jar;C:\Java\jdk1.8.0_321\jre\lib\javaws.jar;C:\Java\jdk1.8.0_321\jre\lib\jce.jar;C:\Java\jdk1.8.0_321\jre\lib\jfr.jar;C:\Java\jdk1.8.0_321\jre\lib\jfxswt.jar;C:\Java\jdk1.8.0_321\jre\lib\jsse.jar;C:\Java\jdk1.8.0_321\jre\lib\management-agent.jar;C:\Java\jdk1.8.0_321\jre\lib\plugin.jar;C:\Java\jdk1.8.0_321\jre\lib\resources.jar;C:\Java\jdk1.8.0_321\jre\lib\rt.jar;D:\xiejiaohui\spring_study_demo\out\production\spring;D:\xiejiaohui\spring_study_demo\lib\commons-logging-1.1.1.jar;D:\xiejiaohui\spring_study_demo\lib\spring-beans-5.2.9.RELEASE.jar;D:\xiejiaohui\spring_study_demo\lib\spring-context-5.2.9.RELEASE.jar;D:\xiejiaohui\spring_study_demo\lib\spring-core-5.2.9.RELEASE.jar;D:\xiejiaohui\spring_study_demo\lib\spring-expression-5.2.9.RELEASE.jar;C:\Users\Administrator\.m2\repository\junit\junit\4.13.1\junit-4.13.1.jar;C:\Users\Administrator\.m2\repository\org\hamcrest\hamcrest-core\1.3\hamcrest-core-1.3.jar" com.intellij.rt.junit.JUnitStarter -ideVersion5 -junit4 com.xjh.study.TestSpring5,testAdd com.xjh.study.User@4923ab24 User add()........ Process finished with exit code 0
标签:jdk1.8,Java,lib,jar,jre,初学,321,Spring5 From: https://www.cnblogs.com/xiejh/p/16927489.html