使用Jhipster设置MSSQL的问题

时间:2016-12-08 11:05:59

标签: sql-server maven-3 jhipster

我试图将jhipster用于我的后端项目,其中一个要求是使用mssql。根据我之前的问题: https://github.com/jhipster/generator-jhipster/issues/4612#issuecomment-265076842

@ruddel确实建议我使用这个

POST

设置完之后我需要运行maven命令,因此可以根据jhipster的指南使用此命令通过liquibase为网关项目和Microservice生成Jhipster初始实体

datasource:
        type: com.zaxxer.hikari.HikariDataSource
        url: jdbc:sqlserver://localhost:1433;database=msqltest
        username: SA
        password: yourStrong(!)Password
        hikari:
                  .........
    jpa:
        database-platform: org.hibernate.dialect.SQLServer2012Dialect
        database: SQL_SERVER
                  .........   

并遇到此错误:

liquibase:diff

所以我再次提到他们提到的jhipster改变了pom.xml中的设置,我按照这样做了:

[INFO] Settings
----------------------------
[INFO]     driver: com.zaxxer.hikari.HikariConfig
[INFO]     url: jdbc:sqlserver://localhost:1433;database=IASDB
[INFO]     username: devuser
[INFO]     password: *****
[INFO]     use empty password: false
[INFO]     properties file: null
[INFO]     properties file will override? false
[INFO]     prompt on non-local database? true
[INFO]     clear checksums? false
[INFO]     changeLogFile: src/main/resources/config/liquibase/master.xml
[INFO]     context(s): null
[INFO]     label(s): null
[INFO]     referenceDriver: null
[INFO]     referenceUrl: hibernate:spring:com.mbb.ias.domain?dialect=org.hibernate.dialect.SQLServer2012Dialect&hibernate.physical_naming_strategy=org.springframework.boot.orm.jpa.hibernate.Spate.implicit_naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy
[INFO]     referenceUsername: null
[INFO]     referencePassword: null
[INFO]     referenceDefaultSchema: null
[INFO]     diffChangeLogFile: src/main/resources/config/liquibase/changelog/20161208102850_changelog.xml
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.109 s
[INFO] Finished at: 2016-12-08T18:28:54+08:00
[INFO] Final Memory: 37M/342M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.liquibase:liquibase-maven-plugin:3.5.3:diff (default-cli) on project ias-gateway: Error setting up or running Liquibase: liquibase.exception.DatabaseExceptionnot find database driver: com.zaxxer.hikari.HikariConfig cannot be cast to java.sql.Driver -> [Help 1]

它会按照上面的msg或者这个来推测错误:

        <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.zaxxer.hikari.HikariConfig</driver>
            <url>jdbc:sqlserver://localhost:1433;database=IASDB</url>
            <defaultSchemaName>IASDB</defaultSchemaName>
            <username>devuser</username>
            <password>CIATopSecret</password>
            <referenceUrl>hibernate:spring:com.mbb.ias.domain?dialect=org.hibernate.dialect.SQLServer2012Dialect&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>

我确实尝试改变我的pom以使用com.microsoft.SQLServerDriver,它抛出我

[ERROR] Failed to execute goal org.liquibase:liquibase-maven-plugin:3.5.3:diff (default-cli) on project ias-gateway: Error setting up or running Liquibase: liquibase.exception.DatabaseExceptionnot find database driver: com.zaxxer.hikari.HikariConfig cannot be cast to java.sql.Driver -> [Help 1]

有人建议如何改变我的pom吗?如果我想使用子生成器,我需要逐个生成实体?对不起这个菜鸟问题。这是我的Jhipster信息:

[ERROR] Failed to execute goal org.liquibase:liquibase-maven-plugin:3.5.3:diff (default-cli) on project ias-gateway: Error setting up or running Liquibase: liquibase.exception.DatabaseExceptionnot find database driver: com.microsoft.SQLServerDriver -> [Help 1]

1 个答案:

答案 0 :(得分:1)

要获得完整的MSSQL支持,您应该使用v3.12.1 - 在我们支持该数据库之前,您的项目是使用v3.12.0生成的。你也不应该最初运行liquibase:diff(它会失败,直到应用程序第一次运行liquibase)。

以下代码是来自新生成项目的MSSQL liquibase的pom配置,我看到的主要区别是驱动程序标记:

            <configuration>
                <changeLogFile>src/main/resources/config/liquibase/master.xml</changeLogFile>
                <diffChangeLogFile>src/main/resources/config/liquibase/changelog/${maven.build.timestamp}_changelog.xml</diffChangeLogFile>
                <driver></driver>
                <url>jdbc:sqlserver://localhost:1433;database=databaseName</url>
                <defaultSchemaName></defaultSchemaName>
                <username>SA</username>
                <password>yourStrong(!)Password</password>
                <referenceUrl>hibernate:spring:com.mycompany.myapp.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>