Dropwizard项目的Maven执行无法正常工作

时间:2018-10-24 05:42:53

标签: java hibernate maven dropwizard

我尝试构建一个Dropwizard应用程序,当我尝试在包含

之后使用mvn exec:java执行它时
<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>exec-maven-plugin</artifactId>
    <version>1.6.0</version>
        <configuration>
            <mainClass>${mainClass}</mainClass> //the application java class from properties tag 
            <arguments>
                <argument>server</argument>
            </arguments>
      </configuration>
</plugin>
使用mvn命令时在命令提示符下输入

> mvn exec:java 希望它可以构建和部署它,而是出现了以下问题

[INFO] --- exec-maven-plugin:1.6.0:java (default-cli) @ hello-dropwizard ---
[WARNING]
java.lang.ArrayIndexOutOfBoundsException: 1
        at org.hibernate.validator.internal.util.Version.getJavaRelease(Version.java:36)
        at org.hibernate.validator.internal.engine.ConfigurationImpl.<init>(ConfigurationImpl.java:120)
        at org.hibernate.validator.internal.engine.ConfigurationImpl.<init>(ConfigurationImpl.java:106)
        at org.hibernate.validator.HibernateValidator.createSpecializedConfiguration(HibernateValidator.java:27)
        at org.hibernate.validator.HibernateValidator.createSpecializedConfiguration(HibernateValidator.java:24)
        at javax.validation.Validation$ProviderSpecificBootstrapImpl.configure(Validation.java:220)
        at io.dropwizard.validation.BaseValidator.newConfiguration(BaseValidator.java:28)
        at io.dropwizard.jersey.validation.Validators.newConfiguration(Validators.java:35)
        at io.dropwizard.jersey.validation.Validators.newValidatorFactory(Validators.java:27)
        at io.dropwizard.setup.Bootstrap.<init>(Bootstrap.java:68)
        at io.dropwizard.Application.run(Application.java:72)
        at com.dropwizard.demo.HeloDropWizardApplication.main

这种行为有什么原因吗?

1 个答案:

答案 0 :(得分:0)

注意到我在系统中安装了Java 9,对休眠验证器类的研究很少,它期望返回8,因为我没有以特定的方式返回9,因为下面的代码

String[] specificationVersion = System.getProperty( "java.specification.version" ).split( "\\." );
return Integer.parseInt( specificationVersion[1] );

即使maven抛出了相同的异常,我也更改了PATH以包括java 1.8路径。 我必须使用> mvn package 然后使用> java -jar target\dropwizarddemo.jar server