當前位置:
首頁 >
java_spring_依赖注入(构造器)
發布時間:2025/3/17
31
豆豆
生活随笔
收集整理的這篇文章主要介紹了
java_spring_依赖注入(构造器)
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
依賴注入對象可以 手工裝配(建議) 和 自動裝配
//配置方法
//Test Class
package com.itcast.www;import static org.junit.Assert.*;import org.junit.BeforeClass; import org.junit.Test; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext;import com.dao.bean.www.PersonServiceDao;public class TestCaseDemo {@BeforeClasspublic static void setUpBeforeClass() throws Exception {}@Testpublic void instanceSpring() {ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");PersonServiceDao personService = (PersonServiceDao) ctx.getBean("personService");personService.save();}}?
轉載于:https://www.cnblogs.com/MarchThree/p/3720410.html
總結
以上是生活随笔為你收集整理的java_spring_依赖注入(构造器)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 大数据之Azkaban部署
- 下一篇: 数据产品-指标体系与数据采集