有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java包括com。凭直觉。空手道依赖导致SpringRunner contextLoad错误

Mac Mojave 10.14.4
当运行这个maven命令时

mvn clean install   

我使用的是Spring Boot 2.1.5-Release,有一个简单的contextLoad测试,只要我包含一个特定版本的com,它就会失败。凭直觉。空手道0.9.2作为pom中的一个依赖项。xml一旦我包含该版本(0.9.2),以便我可以围绕它开发测试,现有的测试就会失败

   <dependency>
        <groupId>com.intuit.karate</groupId>
        <artifactId>karate-apache</artifactId>
        <version>0.9.2</version>
        <scope>test</scope>
    </dependency>
    <!-- karate test deps -->
    <dependency>
        <groupId>com.intuit.karate</groupId>
        <artifactId>karate-junit5</artifactId>
        <version>0.9.2</version>
        <scope>test</scope>
    </dependency>

我降级到0.9.1版,问题就消失了。 也可以通过修改pom。排除它的xml也起作用

    <dependency>
        <groupId>com.intuit.karate</groupId>
        <artifactId>karate-apache</artifactId>
        <version>0.9.2</version>
        <scope>test</scope>
        <exclusions>
            <exclusion>
                <groupId>org.openjfx</groupId>
                <artifactId>javafx-controls</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <!-- karate test deps -->
    <dependency>
        <groupId>com.intuit.karate</groupId>
        <artifactId>karate-junit5</artifactId>
        <version>0.9.2</version>
        <scope>test</scope>
        <exclusions>
            <exclusion>
                <groupId>org.openjfx</groupId>
                <artifactId>javafx-controls</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

它似乎被缩小到这个可传递的依赖包含,当排除它时,它可以正常工作。我看不到任何关系会导致SpringRunner测试失败,除非它在libXXX中。动态文件

      <dependency>
        <groupId>org.openjfx</groupId>
        <artifactId>javafx-controls</artifactId>
        <version>12-ea+9</version>
        <scope>test</scope>
        <exclusions>
            <exclusion>
                <groupId>org.openjfx</groupId>
                <artifactId>javafx-graphics</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
@RunWith(SpringRunner.class)
@SpringBootTest
public class JugToursApplicationTests {

    @Test
    public void contextLoads() {
    }
}

日志:

    2019-05-17 13:14:50.311  INFO 2885 --- [           main] c.s.e.s.JugToursApplicationTests         : Starting JugToursApplicationTests on svuslp00099.local with PID 2885 (started by chesterpressler in /Users/chesterpressler/development/spring-react)
    2019-05-17 13:14:50.314  INFO 2885 --- [           main] c.s.e.s.JugToursApplicationTests         : No active profile set, falling back to default profiles: default
    2019-05-17 13:14:51.766  INFO 2885 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data repositories in DEFAULT mode.
    2019-05-17 13:14:51.842  INFO 2885 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 65ms. Found 2 repository interfaces.
    2019-05-17 13:14:52.403  INFO 2885 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$e99c3d5a] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
    2019-05-17 13:14:52.757  INFO 2885 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Starting...
    2019-05-17 13:14:53.008  INFO 2885 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Start completed.
    2019-05-17 13:14:53.098  INFO 2885 --- [           main] o.hibernate.jpa.internal.util.LogHelper  : HHH000204: Processing PersistenceUnitInfo [
            name: default
            ...]
    2019-05-17 13:14:53.171  INFO 2885 --- [           main] org.hibernate.Version                    : HHH000412: Hibernate Core {5.3.10.Final}
    2019-05-17 13:14:53.174  INFO 2885 --- [           main] org.hibernate.cfg.Environment            : HHH000206: hibernate.properties not found
    2019-05-17 13:14:53.428  INFO 2885 --- [           main] o.hibernate.annotations.common.Version   : HCANN000001: Hibernate Commons Annotations {5.0.4.Final}
    2019-05-17 13:14:53.587  INFO 2885 --- [           main] org.hibernate.dialect.Dialect            : HHH000400: Using dialect: org.hibernate.dialect.H2Dialect
    2019-05-17 13:14:53.964  WARN 2885 --- [           main] o.s.w.c.s.GenericWebApplicationContext   : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory; nested exception is org.hibernate.cfg.beanvalidation.IntegrationException: Error activating Bean Validation integration
    2019-05-17 13:14:53.965  INFO 2885 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown initiated...
    2019-05-17 13:14:53.970  INFO 2885 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown completed.
    2019-05-17 13:14:53.986  INFO 2885 --- [           main] ConditionEvaluationReportLoggingListener : 

    Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
    2019-05-17 13:14:54.000 ERROR 2885 --- [           main] o.s.boot.SpringApplication               : Application run failed

    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory; nested exception is org.hibernate.cfg.beanvalidation.IntegrationException: Error activating Bean Validation integration
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1778) ~[spring-beans-5.1.7.RELEASE.jar:5.1.7.RELEASE]
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:593) ~[spring-beans-5.1.7.RELEASE.jar:5.1.7.RELEASE]
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515) ~[spring-beans-5.1.7.RELEASE.jar:5.1.7.RELEASE]
            at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320) ~[spring-beans-5.1.7.RELEASE.jar:5.1.7.RELEASE]
            at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.1.7.RELEASE.jar:5.1.7.RELEASE]
            at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318) ~[spring-beans-5.1.7.RELEASE.jar:5.1.7.RELEASE]
            at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.1.7.RELEASE.jar:5.1.7.RELEASE]
            at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1105) ~[spring-context-5.1.7.RELEASE.jar:5.1.7.RELEASE]
            at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:867) ~[spring-context-5.1.7.RELEASE.jar:5.1.7.RELEASE]
            at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549) ~[spring-context-5.1.7.RELEASE.jar:5.1.7.RELEASE]
            at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:775) ~[spring-boot-2.1.5.RELEASE.jar:2.1.5.RELEASE]
            at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) ~[spring-boot-2.1.5.RELEASE.jar:2.1.5.RELEASE]
            at org.springframework.boot.SpringApplication.run(SpringApplication.java:316) ~[spring-boot-2.1.5.RELEASE.jar:2.1.5.RELEASE]
            at org.springframework.boot.test.context.SpringBootContextLoader.loadContext(SpringBootContextLoader.java:127) [spring-boot-test-2.1.5.RELEASE.jar:2.1.5.RELEASE]
            at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:99) [spring-test-5.1.7.RELEASE.jar:5.1.7.RELEASE]

共 (1) 个答案

  1. # 1 楼答案

    好的,根据你的报告,很明显我们在JavaFX和Spring/Boot上有一个奇怪的依赖性问题

    我们开了一张票:https://github.com/intuit/karate/issues/780

    谢谢你的排除信息。如果你能创建一个最小的快速启动,可以复制这个(并提到你的JDK版本),这将有所帮助