【Java开源代码栏目提醒】:以下是网学会员为您推荐的Java开源代码-ConInjectionTest.java,希望本篇文章对您学习有所帮助。
package constructor;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class ConInjectionTest {
private Company company;
private Worker worker;
public ConInjectionTest(Company company, Worker worker) {
super();
this.company = company;
this.worker = worker;
}
public Company getCompany() {
return company;
}
public void setCompany(Company company) {
this.company = company;
}
public Worker getWorker() {
return worker;
}
public void setWorker(Worker worker) {
this.worker = worker;
}
public static void main(String[] args)
{
ApplicationContext context = new ClassPathXmlApplicationContext("constructor/beans.
xml");
ConInjectionTest test = (ConInjectionTest)context.getBean("constructorBean");
System.out.println("test.company.getCompanyID()="+test.company.getCompanyID());
System.out.println("test.company.getName()="+test.company.getName());
System.out.println("test.worker.getWID()="+test.worker.getWID());
System.out.println("test.worker.getName="+test.worker.getName());
System.out.println("test.worker.getDepartment()="+test.worker.getDepartment());
}
}