0

vFabric tc サーバーを使用して Spring Tool Suite (STS) 内に Web アプリをデプロイしようとしていますが、例外が発生します。スタンドアロンの Tomcat 6 でコンパイルして実行すると問題なく動作することは注目に値します。

エラーは次のとおりです。

java.lang.IllegalArgumentException: class [springapp.web.spring.MyInitializer] must implement ApplicationContextInitializerclass springapp.web.spring.MyInitializer is not assignable to interface org.springframework.context.ApplicationContextInitializer

イニシャライザが実装しているため、このエラーが発生する理由を解読できませんApplicationContextInitializer

public class MyInitializer implements ApplicationContextInitializer {
  public void initialize(ConfigurableApplicationContext ctx) {
    try {
        PropertySource ps = new ResourcePropertySource("file:///home/jim/development/act/impact/webapp.properties");
        ctx.getEnvironment().getPropertySources().addFirst(ps);
        // perform any other initialization of the context ...
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
  }
}

これを実行するために私ができることについて何か提案はありますか?

4

2 に答える 2

2

アプリケーション サーバーには、異なるバージョンのorg.springframework.context.ApplicationContextInitializerクラス ( spring-contextjar 内) があります。これは通常、jar をファット ウォーとアプリケーション サーバー自身のクラスパスの両方に置くことによって発生します。一般に、システム クラスパスにシステム API (サーブレットなど) 以外のものを含めないようにし、各アプリケーションに必要な jar を含める必要があります。

于 2013-11-15T11:49:57.643 に答える
0

なぜこれが起こったのかわかりませんが、問題は私のpomファイルにあることが判明しましたspring-context-support

<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-context-suppoer</artifactId>
    <version>3.2.2.RELEASE</version>
    <type>pom</type>
</dependency>

要素を削除するとtype、問題が修正されました。

于 2013-11-15T13:32:08.660 に答える