【问题标题】:Multiple dependencies with hibernate.cfg.xml at root in shaded jarhibernate.cfg.xml 在阴影 jar 中的根目录中的多个依赖项
【发布时间】:2021-09-27 11:32:28
【问题描述】:

我正在尝试为一个具有多个依赖项实现休眠实体的 jar 遮蔽。许多依赖项在 jar 的根目录下都有 hibernate.cfg.xml,因此只有一个不确定的 hibernate.cfg.xml 被添加到最终的 jar 中。玩弄附加的变压器,但到目前为止还没有运气。

提前感谢您的任何建议!

<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
    <resource>**/hibernate.cfg.xml</resource>
</transformer>

【问题讨论】:

    标签: java hibernate maven-shade-plugin


    【解决方案1】:

    我有点放弃了——要处理的依赖项太多,失败了:(我使用了标准 jar 和库目录。

                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-dependency-plugin</artifactId>
                        <version>3.2.0</version>
                        <executions>
                            <execution>
                                <id>copy-libs</id>
                                <phase>prepare-package</phase>
                                <goals>
                                    <goal>copy-dependencies</goal>
                                </goals>
                                <configuration>
                                    <outputDirectory>${project.build.directory}/libs</outputDirectory>
                                    <includeScope>runtime</includeScope>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-jar-plugin</artifactId>
                        <version>3.2.0</version>
                        <configuration>
                            <outputDirectory>${project.build.directory}/bin</outputDirectory>
                            <archive>
                                <manifest>
                                    <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                                    <addClasspath>true</addClasspath>
                                    <useUniqueVersions>false</useUniqueVersions>
                                    <mainClass>com.loader.App</mainClass>
                                    <classpathPrefix>../libs/</classpathPrefix>
                                </manifest>
                            </archive>
                        </configuration>
                    </plugin>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-12-16
      • 1970-01-01
      • 2015-05-31
      • 2017-08-04
      • 1970-01-01
      • 2019-08-04
      • 1970-01-01
      • 2013-05-04
      相关资源
      最近更新 更多