本文介绍了如何使用maven执行第三方jar的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用(通过其)来处理数据库迁移。

I am using Liquibase (via its Maven plugin) to handle database migrations.

然而,并非所有Liquibase功能都可以通过Maven获得。其中一个特别是,只能通过(使用可下载的liquibase.jar),其命令如下:

However not all Liquibase features are available via Maven. One in particular, Generate Changelog, is only available via the command line (using the downloadable liquibase.jar) with a command like this:

java -jar liquibase.jar \
--driver=oracle.jdbc.OracleDriver \
--classpath=\path\to\classes:jdbcdriver.jar \
--changeLogFile=com/example/db.changelog.xml \
--url="jdbc:oracle:thin:@localhost:1521:XE" \
--username=scott \
--password=tiger \
generateChangeLog

如何通过Maven可移植地执行此命令?也就是说,我不想将liquibase.jar文件添加到我的项目结构中。

How can I execute this command via Maven, portably? That is, I do not want to have to add the liquibase.jar file to my project structure.

相反,我想将它列为依赖项(我可以手动将jar添加到我的本地存储库或Nexus代理),然后在使用类似的东西时引用它的 exec:java exec:exec 目标,但我无法看到如何使用具有这些目标的可执行jar来执行此操作。 :(

Instead, I would like to list it as a dependency (I could manually add the jar to my local repository or Nexus proxy) and then reference it when using something like the Exec Maven Plugin's exec:java or exec:exec goals, but I can't see how to do this using an executable jar with those goals. :(

我们非常感谢任何建议。

Any suggestions would be much appreciated.

谢谢!

推荐答案

我不知道,但可能会对你有帮助。

I don't know, but may be this will help you.

尝试使用maven exec插件和put作为mainClass配置参数:liquibase.integration.commandline.Main

Try to use maven exec plugin and put as a mainClass configuration param this: liquibase.integration.commandline.Main

我从你的jar文件中的MANIFEST.MF得到它

I get it from MANIFEST.MF from your jar file

  <plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>exec-maven-plugin</artifactId>
    <version>1.2.1</version>
    <executions>
      <execution>
        ...
        <goals>
          <goal>java</goal>
        </goals>
      </execution>
    </executions>
    <configuration>
      <mainClass>liquibase.integration.commandline.Main</mainClass>
      <arguments>
        <argument>--driver=oracle.jdbc.OracleDriver</argument>
        <argument>--changeLogFile=com/example/db.changelog.xml</argument>
        ...
      </arguments>
    </configuration>
  </plugin>

这篇关于如何使用maven执行第三方jar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-03 21:59
查看更多