簡體   English   中英

JHipster微服務Maven構建失敗(無法確定數據庫類型NONE的嵌入式數據庫驅動程序類)

[英]JHipster Microservice Maven Build Failure (Cannot determine embedded database driver class for database type NONE)

我正在嘗試使用Maven構建JHipster微服務,但是每當我使用Dev以外的配置文件時,我都會收到以下錯誤消息

Failed to instantiate [org.apache.tomcat.jdbc.pool.DataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Cannot determine embedded database driver class for database type NONE

JHipster 4.5.1

的pom.xml

<configuration>
    <changeLogFile>src/main/resources/config/liquibase/master.xml</changeLogFile>
    <diffChangeLogFile>src/main/resources/config/liquibase/changelog/${maven.build.timestamp}_changelog.xml</diffChangeLogFile>
    <driver>com.microsoft.sqlserver.jdbc.SQLServerDriver</driver>
    <url>jdbc:sqlserver://serverdetails;</url>
    <defaultSchemaName></defaultSchemaName>
    <username>myuser</username>
    <password>mypa$$word</password>
    <referenceUrl>hibernate:spring:com.company.project.domain?dialect=org.hibernate.dialect.SQLServerDialect&amp;hibernate.physical_naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy&amp;hibernate.implicit_naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy</referenceUrl>
    <verbose>true</verbose>
    <logging>debug</logging>
</configuration>

application.yml

datasource:
    type: com.zaxxer.hikari.HikariDataSource
    url: jdbc:sqlserver://serverdetails;
    username: myuser
    password: mypa$$word
    hikari:
        data-source-properties:
            cachePrepStmts: true
            prepStmtCacheSize: 250
            prepStmtCacheSqlLimit: 2048
            useServerPrepStmts: true
jpa:
    database-platform: org.hibernate.dialect.SQLServer2012Dialect
    database: SQL_SERVER
    show-sql: false
    properties:
        hibernate.id.new_generator_mappings: true
        hibernate.cache.use_second_level_cache: false
        hibernate.cache.use_query_cache: false
        hibernate.generate_statistics: false

從IntelliJ運行我的開發人員配置文件可以正常工作並連接到數據庫。 針對開發人員配置文件運行Maven構建也可以正常工作。 只是當我切換到另一個時,才獲得下面的完整堆棧跟蹤。

2017-06-30 10:34:30.589  INFO 13148 --- [  restartedMain] com.company.project.MicroApi          : The following profiles are active: prod{profile.no-liquibase}
2017-06-30 10:34:36.373  INFO 13148 --- [  restartedMain] c.company.project.config.WebConfigurer  : Web application configuration, using profiles: prod{profile.no-liquibase}
2017-06-30 10:34:36.516  INFO 13148 --- [  restartedMain] c.company.project.config.WebConfigurer  : Web application fully configured
2017-06-30 10:34:36.792  WARN 13148 --- [  restartedMain] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'liquibase' defined in class path resource [com/company/project/config/DatabaseConfiguration.class]: Unsatisfied dependency expressed through method 'liquibase' parameter 1; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Tomcat.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.tomcat.jdbc.pool.DataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Cannot determine embedded database driver class for database type NONE. If you want an embedded database please put a supported one on the classpath. If you have database settings to be loaded from a particular profile you may need to active it (the profiles "prod{profile.no-liquibase}" are currently active).
2017-06-30 10:34:36.979  WARN 13148 --- [  restartedMain] o.s.boot.SpringApplication               : Error handling failed (Error creating bean with name 'delegatingApplicationListener' defined in class path resource [org/springframework/security/config/annotation/web/configuration/WebSecurityConfiguration.class]: BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.config.internalTransactionAdvisor' defined in class path resource [org/springframework/transaction/annotation/ProxyTransactionManagementConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.transaction.interceptor.BeanFactoryTransactionAttributeSourceAdvisor]: Factory method 'transactionAdvisor' threw exception; nested exception is java.lang.NullPointerException)
2017-06-30 10:34:37.112 ERROR 13148 --- [  restartedMain] o.s.b.d.LoggingFailureAnalysisReporter   : 

我是否需要在項目中的某個地方包含jdbc驅動程序?

我看過以下報告類似問題的鏈接,但是它們的解決方案似乎對我沒有什么影響(或者我只是不理解它們)。

https://github.com/jhipster/generator-jhipster/issues/1610 無法確定數據庫類型為NONE的嵌入式數據庫驅動程序類 Spring boot + Hibernate

謝謝你提供的所有幫助。

完整日志如下;

"C:\Program Files\Java\jdk1.8.0_121\bin\java" -Dmaven.multiModuleProjectDirectory=C:\MyFolder "-Dmaven.home=C:\Program Files\JetBrains\IntelliJ IDEA 2017.1.3\plugins\maven\lib\maven3" "-Dclassworlds.conf=C:\Program Files\JetBrains\IntelliJ IDEA 2017.1.3\plugins\maven\lib\maven3\bin\m2.conf" "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA 2017.1.3\lib\idea_rt.jar=59123:C:\Program Files\JetBrains\IntelliJ IDEA 2017.1.3\bin" -Dfile.encoding=UTF-8 -classpath "C:\Program Files\JetBrains\IntelliJ IDEA 2017.1.3\plugins\maven\lib\maven3\boot\plexus-classworlds-2.5.2.jar" org.codehaus.classworlds.Launcher -Didea.version=2017.1.4 spring-boot:run -P prod,no-liquibase,IDE,!dev
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building Scrn Api 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] >>> spring-boot-maven-plugin:1.5.3.RELEASE:run (default-cli) > test-compile @ microApi >>>
[INFO] 
[INFO] --- maven-resources-plugin:3.0.1:copy-resources (default-resources) @ microApi ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 68 resources
[INFO] Copying 5 resources
[INFO] 
[INFO] --- maven-resources-plugin:3.0.1:resources (default-resources) @ microApi ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 68 resources
[INFO] Copying 5 resources
[INFO] 
[INFO] --- maven-enforcer-plugin:1.4.1:enforce (enforce-versions) @ microApi ---
[INFO] 
[INFO] --- jacoco-maven-plugin:0.7.9:prepare-agent (pre-unit-tests) @ microApi ---
[INFO] argLine set to -javaagent:C:\\MyFolder\\.m2\\repository\\org\\jacoco\\org.jacoco.agent\\0.7.9\\org.jacoco.agent-0.7.9-runtime.jar=destfile=C:\\MyFolder\\target\\test-results\\coverage\\jacoco\\jacoco.exec -Djava.security.egd=file:/dev/./urandom -Xmx256m
[INFO] 
[INFO] --- spring-boot-maven-plugin:1.5.3.RELEASE:build-info (default) @ microApi ---
[INFO] 
[INFO] --- maven-compiler-plugin:3.6.0:compile (default-compile) @ microApi ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 206 source files to C:\MyFolder\target\classes
[INFO] 
[INFO] --- maven-resources-plugin:3.0.1:testResources (default-testResources) @ microApi ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 3 resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.6.0:testCompile (default-testCompile) @ microApi ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] <<< spring-boot-maven-plugin:1.5.3.RELEASE:run (default-cli) < test-compile @ microApi <<<
[INFO] 
[INFO] --- spring-boot-maven-plugin:1.5.3.RELEASE:run (default-cli) @ microApi ---
[INFO] Attaching agents: []

        ??? ???   ??? ????????? ????????   ??????? ????????? ????????? ????????
        ??? ???   ??? ????????? ????????? ???????? ????????? ????????? ?????????
        ??? ?????????    ???    ????????? ???????     ???    ???????   ?????????
  ???   ??? ?????????    ???    ????????   ???????    ???    ???????   ????????
  ????????? ???   ??? ????????? ???       ????????    ???    ????????? ???  ????
   ???????  ???   ??? ????????? ???       ???????     ???    ????????? ???   ???

:: JHipster ?  :: Running Spring Boot 1.5.3.RELEASE ::
:: http://jhipster.github.io ::

2017-06-30 12:57:51.837  INFO 4520 --- [           main] com.company.project.ScrnApiApp          : The following profiles are active: prod{profile.no-liquibase}
2017-06-30 12:57:57.706  INFO 4520 --- [           main] c.company.project.config.WebConfigurer  : Web application configuration, using profiles: prod{profile.no-liquibase}
2017-06-30 12:57:57.845  INFO 4520 --- [           main] c.company.project.config.WebConfigurer  : Web application fully configured
2017-06-30 12:57:58.164  WARN 4520 --- [           main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'liquibase' defined in class path resource [com/company/project/config/DatabaseConfiguration.class]: Unsatisfied dependency expressed through method 'liquibase' parameter 1; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Tomcat.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.tomcat.jdbc.pool.DataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Cannot determine embedded database driver class for database type NONE. If you want an embedded database please put a supported one on the classpath. If you have database settings to be loaded from a particular profile you may need to active it (the profiles "prod{profile.no-liquibase}" are currently active).
2017-06-30 12:57:58.306  WARN 4520 --- [           main] o.s.boot.SpringApplication               : Error handling failed (Error creating bean with name 'delegatingApplicationListener' defined in class path resource [org/springframework/security/config/annotation/web/configuration/WebSecurityConfiguration.class]: BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.config.internalTransactionAdvisor' defined in class path resource [org/springframework/transaction/annotation/ProxyTransactionManagementConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.transaction.interceptor.BeanFactoryTransactionAttributeSourceAdvisor]: Factory method 'transactionAdvisor' threw exception; nested exception is java.lang.NullPointerException)
2017-06-30 12:57:58.431 ERROR 4520 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 

***************************
APPLICATION FAILED TO START
***************************

Description:

Cannot determine embedded database driver class for database type NONE

Action:

If you want an embedded database please put a supported one on the classpath. If you have database settings to be loaded from a particular profile you may need to active it (the profiles "prod{profile.no-liquibase}" are currently active).

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 35.694 s
[INFO] Finished at: 2017-06-30T12:57:58+01:00
[INFO] Final Memory: 53M/492M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:1.5.3.RELEASE:run (default-cli) on project microApi: Could not exec java: Application finished with exit code: 1 -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

Process finished with exit code 1

我還嘗試將以下依賴項添加到Pom.xml中

                <dependency>
                    <groupId>com.microsoft.sqlserver</groupId>
                    <artifactId>mssql-jdbc</artifactId>
                    <version>6.1.0.jre8</version>
                </dependency>

我最近遇到了這個問題,我不小心刪除了

<driver>

來自我pom的標簽

必須設置它,我的看起來像:

<plugin>
    <groupId>org.liquibase</groupId>
    <artifactId>liquibase-maven-plugin</artifactId>
    <version>${liquibase.version}</version>
    <configuration>
        <changeLogFile>src/main/resources/config/liquibase/master.xml</changeLogFile>
        <diffChangeLogFile>src/main/resources/config/liquibase/changelog/${maven.build.timestamp}_changelog.xml</diffChangeLogFile>
        <driver>com.microsoft.sqlserver.jdbc.SQLServerDriver</driver>
        <url>jdbc:sqlserver://...</url>
        <defaultSchemaName></defaultSchemaName>
        <username>your db name here</username>
        <password>password here</password>
        <referenceUrl>hibernate:spring:com...domain?dialect=org.hibernate.dialect.SQLServerDialect&amp;hibernate.physical_naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy&amp;hibernate.implicit_naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy</referenceUrl>
        <verbose>true</verbose>
        <logging>debug</logging>
    </configuration>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM