加载语句如下:

。。。。。
 static BeanFactory beanFactory;
  public void start(BundleContext context) throws Exception {
  super.start(context);
  initSpring();
  plugin = this;
 }

  private void initSpring() {
  ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
  try {
   Object o = this.getClass().getClassLoader();
   Thread.currentThread().setContextClassLoader((ClassLoader) o);
   beanFactory = new ClassPathXmlApplicationContext(
     "/applicationContext.xml");
  } finally {
   Thread.currentThread().setContextClassLoader(oldLoader);
  }

 }

 public static BeanFactory getBeanFactory() {
  return beanFactory;
 }

以上内容加入后:

将改语句放在了Activator的start里。因为RCP是延迟加载,需要使用Spring容器的时候,所需要的包还未加载。因此,要将以上语句放在Activator插件加载之前,实现立即加载。新建一个类实现IStartup家口。加载RCP扩展点。

 

Spring的配置文件中的头部:

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context-2.5.xsd">

 

由于不能连接外网而找不到XSD文件,但是加载的Spring.jar包中有,系统却关联不上(该RCP工程,将所有要使用的jar包都放在了一个同意的插件中)。此处是因为,虽然第三方包的插件的jar所有的都暴露给了其他的插件,但是spring.handlers却找不到,所以,只能将spring.jar包放到使用spring配置文件的插件中

   在PLUGIN.XML中RUNTIME加入classpath中加入JAR包.

 

,从而才能解决这个问题。

 

相关文章:

  • 2022-01-12
  • 2021-07-07
  • 2021-12-17
  • 2022-12-23
  • 2021-11-24
  • 2021-04-24
  • 2021-07-25
  • 2022-01-16
猜你喜欢
  • 2021-06-20
  • 2021-08-28
  • 2022-01-01
  • 2022-12-23
  • 2021-11-20
  • 2021-07-12
  • 2022-01-24
相关资源
相似解决方案