1. 下載maven到指定目錄,指定對應的gpg的執行命令所須要的屬性。這裏好比下載解壓後的maven目錄是: C:\maven-apache-3.3.2 ,那麼配置文件目錄是: C:\maven-apache-3.3.2\conf\settings.xmlapache
<profiles> <profile> <id>ossrh</id> <activation> <activeByDefault>true</activeByDefault> </activation> <properties> <gpg.executable>gpg2</gpg.executable> <gpg.passphrase>the_pass_phrase</gpg.passphrase> </properties> </profile> </profiles>
2. 在maven的pom.xml文件中配置運行的maven插件.maven
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-gpg-plugin</artifactId> <version>${maven-gpg-plugin.version}</version> <executions> <execution> <id>sign-artifacts</id> <phase>verify</phase> <goals> <goal>sign</goal> </goals> <!-- <configuration> <executable>gpg</executable> <homedir>${gpg.homedir}</homedir> <keyname>${gpg.keyname}</keyname> <passphrase>${gpg.passphrase}</passphrase> </configuration> --> </execution> </executions> </plugin>