相关疑难解决方法(0)

如何使用Maven创建具有依赖关系的可执行JAR?

我想将我的项目打包在一个可执行的JAR中进行分发.

如何将所有依赖JAR的Maven项目打包到我的输出JAR中?

java build-automation build-process maven-2 executable-jar

2276
推荐指数
28
解决办法
123万
查看次数

尝试运行.jar时"无效的签名文件"

我的java程序打包在一个jar文件中,并使用外部jar库,bouncy castle.我的代码编译得很好,但是运行jar会导致以下错误:

线程"main"中的异常java.lang.SecurityException:Manifest主要属性的签名文件摘要无效

我用谷歌搜索了一个多小时寻找解释,发现很少有价值.如果有人以前看过这个错误并且可以提供一些帮助,我将不得不承担责任.

java jar executable-jar

434
推荐指数
11
解决办法
23万
查看次数

强制Maven将依赖项复制到target/lib中

如何将项目的运行时依赖项复制到target/lib文件夹中?

因为它是现在,后mvn clean installtarget文件夹仅包含我的项目的罐子,但没有运行时依赖的.

java dependencies maven-2 maven-3 maven

241
推荐指数
11
解决办法
24万
查看次数

如何:Eclipse Maven安装带有依赖项的构建jar

我在Eclipse中使用Eclipse Maven(m2e),我正在运行我的项目:

pom.xml看起来像这样:

<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>
    <groupId>ro.project</groupId>
    <packaging>jar</packaging>
    <version>1.0-SNAPSHOT</version>
    <name>ro.project</name>

    <properties>
        <org.springframework.version>3.1.1.RELEASE</org.springframework.version>
        <org.hibernate.version>4.1.0.Final</org.hibernate.version>
    </properties>
    <dependencies>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>${org.springframework.version}</version>
        </dependency>
    <build>
        <plugins>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <configuration>
                    <archive>
                        <manifest>
                            <addClasspath>true</addClasspath>
                            <classpathPrefix>lib/</classpathPrefix>
                            <mainClass>ro.project.ProjectServer</mainClass>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-antrun-plugin</artifactId>
                <dependencies>
                    <dependency>
                        <groupId>com.sun</groupId>
                        <artifactId>tools</artifactId>
                        <version>1.7.0_02</version>
                        <scope>system</scope>
                        <systemPath>${java.home}/../lib/tools.jar</systemPath>
                    </dependency>
                </dependencies>
                <executions>
                    <execution>
                        <id>ant-magic</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <configuration>
                            <tasks>
                                <property name="compile_classpath" refid="maven.compile.classpath" />
                                <property name="runtime_classpath" refid="maven.runtime.classpath" />
                                <property name="test_classpath" refid="maven.test.classpath" />
                                <property name="plugin_classpath" refid="maven.plugin.classpath" />

                                <ant antfile="${basedir}/clientExport.xml" target="export-all" /> …
Run Code Online (Sandbox Code Playgroud)

java dependencies m2eclipse maven-3 maven

19
推荐指数
1
解决办法
8万
查看次数

使用 Maven Shade 插件创建包含依赖 jar 的依赖文件夹

我正在使用 Maven Shade 插件创建一个胖罐子,其中也包括一些充气城堡罐子。但这会产生问题,因为 Bouncy Castle 的未签名版本。

java.lang.SecurityException:JCE 无法验证提供者 BC

现在解决方案之一是拥有依赖项的外部文件夹并在 fat jar 的清单文件中定义此类路径。

例如:

<plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-shade-plugin</artifactId>
            <version>2.4.3</version>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>shade</goal>
                    </goals>
                    <configuration>
                            <artifactSet>
                                <excludes>
                                    <exclude>org.bouncycastle:*:*:*</exclude>
                                </excludes>
                            </artifactSet>
                        <finalName>Relay-S3-Monitor-jar-with-dependencies</finalName>
                        <filters>
                            <filter>
                                <artifact>*:*</artifact>
                                <excludes>
                                    <exclude>META-INF/*.SF</exclude>
                                    <exclude>META-INF/*.DSA</exclude>
                                    <exclude>META-INF/*.RSA</exclude>
                                </excludes>
                            </filter>
                        </filters>
                        <transformers>
                            <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                <mainClass>at.seresunit.lecturemanager_connector.App</mainClass>
                            </transformer>
                            <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                                <resource>META-INF/spring.handlers</resource>
                            </transformer>
                            <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                                <resource>META-INF/spring.schemas</resource>
                            </transformer>
                            <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                 <manifestEntries>
                                    <Main-Class>com.pb.relay.s3.CamelBoot</Main-Class>
                                    <Class-Path>. bouncycastle_libs/bcpg-jdk15on-1.55.jar bouncycastle_libs/bcprov-jdk15on-1.55.jar bouncycastle_libs/bcprov-jdk16-1.45.jar</Class-Path>
                                </manifestEntries>
                            </transformer>
                        </transformers>
                    </configuration>
                </execution>
            </executions>
        </plugin
Run Code Online (Sandbox Code Playgroud)

现在我需要的是:在同一个 pom.xml 中,我需要插入一个创建依赖项文件夹的部分(插件)(仅包含 bouncy castle jar)

bouncycastle maven maven-shade-plugin

5
推荐指数
1
解决办法
2670
查看次数