Maven + jarsigner + 测试类 = 错误

Ram*_*sha 6 junit jarsigner maven

我有一个包含一些测试用例的 Maven 项目。今天我尝试添加 jarsigner 插件,现在测试失败:

java.lang.SecurityException:类“types.AccountType”的签名者信息与同一包中其他类的签名者信息不匹配

测试类在同一个包中,可以访问包私有方法等。我相信发生这个错误是因为在测试类时,junit 测试类没有被签名。

有没有人有关于如何避免这个问题的建议?我有一些想法,但不知道如何实现它们:

  1. 导致测试阶段使用类而不是 jar 文件。
  2. 将测试类放入自己的 jar 文件中并签名。

Roc*_*ace 1

我今天遇到了这个问题,问题正如您多年前所猜测的那样(签名订单问题)。这对我来说是解决方案(更改安装阶段):

        <plugin>
            <artifactId>maven-jarsigner-plugin</artifactId>
            <version>${maven-jarsigner-plugin.version}</version>
            <executions>
                <execution>
                    <id>sign</id>
                    <!-- note: this needs to be bound after integration tests or they will fail re: not signed -->
                    <phase>install</phase>
                    <goals>
                        <goal>sign</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <tsa>http://sha256timestamp.ws.symantec.com/sha256/timestamp</tsa>
                <keystore>${project.basedir}/.conf/Keystore</keystore>
                <alias>Alias</alias>
                <storepass>{1234}</storepass>
            </configuration>
        </plugin>
Run Code Online (Sandbox Code Playgroud)

jar 仍然被签名,集成测试再次工作。