我有一个填充了初始数据的JSON文件。有时我需要更新它,我有一个特殊的java类,主要方法负责更新。 在构建jar时有没有办法运行这个方法?
答案 0 :(得分:0)
您可以使用Exec Maven Plugin
mvn exec:java -Dexec.mainClass="com.example.Main" [-Dexec.args="argument1"] ...
示例pom:
<project>
...
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<executions>
<execution>
...
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>com.example.Main</mainClass>
<arguments>
<argument>argument1</argument>
...
</arguments>
<systemProperties>
<systemProperty>
<key>myproperty</key>
<value>myvalue</value>
</systemProperty>
...
</systemProperties>
</configuration>
</plugin>
</plugins>
</build>
...
</project>