Spring从jar文件加载applicationContext

时间:2013-07-02 05:22:31

标签: java spring java-ee jar applicationcontext

我想从jar文件(common-1.0.jar)加载applicationContext。我在独立应用程序中使用了这些步骤,

pom文件中的

    <dependency>
    <groupId>com.cityid</groupId>
    <artifactId>common</artifactId>
    <version>1.0</version>
    </dependency>

之后我使用:

    private static BeanFactory factory = null;
    ClassPathXmlApplicationContext appContext = new ClassPathXmlApplicationContext(
    new String[] {"spring/mainContext.xml"});
    factory = (BeanFactory) appContext;
    PartyFacade partyFacade = (PartyFacade) factory.getBean("partyFacade");
    //Party party = new PartyFacade(); //Entity
    partyFacade.fillParty();

我可以加载PartyFacadeBean但是我无法加载新的实体,例如Party它会抛出nullpoint异常!这种方法适用于Beans,它对DAO或Entity不起作用。如何使用新实体并将它们单独填写?

0 个答案:

没有答案