0

我的问题类似于不久前发布的问题 当外部库位于 EAR 的 lib 文件夹中时,Spring Data Repos 的自动装配失败。

当所有 jar 都包含在WEB-INF/lib 中时,接线工作正常。 我尝试将'skinnyWar'设置为false,但这会复制EAR和WAR中的jar。

该应用程序使用基于 Spring 3.2.2 的 Spring Batch Admin 1.2.2 和 Spring Data 1.1。 使用的Maven 版本3.3。运行时是Websphere 7.x

我有另一个应用程序在将 skinnywar 设置为 true 的情况下工作得非常好——它使用 spring-ws,spring-data 4.0.x 版本。

战争 POM

    <?xml version="1.0" encoding="UTF-8"?>
    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <artifactId>batchadmin-web</artifactId>
    <parent>
    <groupId>com.xyz.interfaces</groupId>
    <artifactId>batch-parent</artifactId>
    <version>1.0.BUILD-SNAPSHOT</version>
    <relativePath>../batch-parent/pom.xml</relativePath>
    </parent>
    <packaging>war</packaging>
    <name>Batch Admin Interface Web</name>
    <dependencies>
<!-- Application specific jars/modules Not included for brevity-->

    </dependencies>

    <build>
            <finalName>springbatch-admin</finalName>
            <outputDirectory>${project.basedir}\src\main\webapp\WEB-INF\classes</outputDirectory>
            <testOutputDirectory>${project.basedir}\src\main\webapp\WEB-INF\classes</testOutputDirectory>
            <plugins>
                    <plugin>
                            <artifactId>maven-war-plugin</artifactId>
                            <version>2.4</version>
                            <configuration>
                                    <archive>
                                             <manifest>
                                                    <addClasspath>true</addClasspath>
                                                    <classpathPrefix>lib/</classpathPrefix>
                                            </manifest>
                                     </archive>
                                       <packagingExcludes>WEB-INF/lib/spring-beans*.jar</packagingExcludes>  
                            </configuration>
                    </plugin>
            </plugins>
    </build>
    </project>

EAR POM 内容:

    <?xml version="1.0" encoding="UTF-8"?>
    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <artifactId>batchadmin-ear</artifactId>
    <parent>
    <groupId>com.xyz.interfaces</groupId>
    <artifactId>batch-parent</artifactId>
    <version>1.0.BUILD-SNAPSHOT</version>
    <relativePath>../batch-parent/pom.xml</relativePath>
    </parent>
    <packaging>ear</packaging>
    <name>Batch Admin Interface</name>
    <dependencies>
            <dependency>
                    <groupId>com.xyz.interfaces</groupId>
                    <artifactId>batchadmin-web</artifactId>
                    <type>war</type>
                    <version>${project.version}</version>
            </dependency>
    </dependencies>
    <build>
            <finalName>SpringBatchEAR</finalName>
            <plugins>
                    <plugin>
                            <groupId>org.apache.maven.plugins</groupId>
                            <artifactId>maven-ear-plugin</artifactId>
                            <version>2.9.1</version>

                            <configuration>
                                    <skinnyWars>true</skinnyWars>
                                    <defaultLibBundleDir>lib/</defaultLibBundleDir>
                                    <modules>
                                            <webModule>
                                                    <groupId>com.xyz.interfaces</groupId>
                                                    <artifactId>batchadmin-web</artifactId>
                                                    <contextRoot>/springbatch-admin</contextRoot>
                                                    <bundleFileName>springbatch-admin.war</bundleFileName>
                                            </webModule>
                                    </modules>

                            </configuration>
                    </plugin>
            </plugins>
    </build>

更新:由于 EAR 只有一个 Web 模块,因此在 Websphere 中将“应用程序的单个类加载器”用于“ WAR 类加载器策略”。这样,我就能完成这项工作。

我想知道如何在不更改类加载器选项的情况下完成这项工作,因为当存在多个 Web 模块时,这可能不是首选。

4

0 回答 0