我正在使用JHipster,当我运行https://other-domain.com/path/to/service-worker.js
时,我收到以下错误
sudo mvn liquibase:diff
我不知道为什么[INFO] Settings
----------------------------
[INFO] driver: org.postgresql.Driver
[INFO] url: jdbc:postgresql://localhost/gastos8
[INFO] username: gastos8
[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.cboujon.domain?dialect=org.hibernate.dialect.PostgreSQL82Dialect
[INFO] referenceUsername: null
[INFO] referencePassword: null
[INFO] referenceDefaultSchema: null
[INFO] diffChangeLogFile: src/main/resources/config/liquibase/changelog/20150807132702_changelog.xml
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 9.554s
[INFO] Finished at: Fri Aug 07 13:27:12 ART 2015
[INFO] Final Memory: 18M/179M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.liquibase:liquibase-maven-plugin:3.3.2:diff (default-cli) on project gastos8: Error setting up or running Liquibase: liquibase.exception.DatabaseException: org.postgresql.util.PSQLException: FATAL: password authentication failed for user "gastos8" -> [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
。
这是我的配置文件:
应用dev.yml
[INFO] username: gastos8
我做错了什么?
答案 0 :(得分:11)
Liquibase maven插件无法读取application.yml以了解如何连接到您的数据库,它在您的pom.xml中有自己的配置。所以你必须把它放在那里。
你为什么要用sudo执行maven? 现在,您可能拥有root拥有的项目文件,这通常是一个坏主意。
答案 1 :(得分:2)
正如在接受的答案中所说,maven没有阅读application.yml。
但是,如果您对maven liquibase插件定义中的数据库配置感到不舒服,则可以使用maven属性和liquibase配置文件。
1 - 在liquibase-maven-plugin
配置中,添加propertyFile
:
<plugin>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-maven-plugin</artifactId>
<version>${liquibase.version}</version>
<configuration>
<propertyFileWillOverride>true</propertyFileWillOverride>
<propertyFile>src/main/resources/liquibase.properties</propertyFile>
</configuration>
(...)
</plugin>
2 - 在src / main / resources下的任何位置创建liquibase属性文件。例如,src / main / resources / config / liquibase:
contexts:${liquibase.contexts}
changeLogFile:src/main/resources/config/liquibase/master.xml
driver:${dataSource.project.driverClass}
url:${dataSource.project.jdbcURL}
username:${dataSource.project.user}
password:${dataSource.project.password}
verbose:true
dropFirst:false
3 - 告诉maven过滤你的liquibase属性文件,以便用maven属性替换值。在<build>
中,请求maven过滤您的liquibase配置文件:
<build>
<resources>
<resource>
<directory>src/main/resources/config/liquibase</directory>
<filtering>true</filtering>
</resource>
</resources>
(...)
</build>
4 - 为允许启动liquibase目标的每个配置文件添加maven属性:
<profile>
<id>dev</id>
(...)
<properties>
<liquibase.contexts></liquibase.contexts>
<dataSource.project.driverClass>org.mariadb.jdbc.Driver</dataSource.project.driverClass>
<dataSource.project.jdbcURL>jdbc:mariadb://localhost:3306/yourDatabaseName</dataSource.project.jdbcURL>
<dataSource.project.user>${datasource.username}</dataSource.project.user>
<dataSource.project.password>${datasource.password}</dataSource.project.password>
</properties>
</profile>
5 - 使用maven启动liquibase目标并在命令行中设置凭据:
mvn resources:resources liquibase:update -Pdev -Ddatasource.username=root -Ddatasource.password=root
答案 2 :(得分:1)
在文件src / main / resources / config / application-dev.yml
中datasource:
driver-class-name: com.mysql.jdbc.jdbc2.optional.MysqlDataSource
url: jdbc:mysql://localhost:3306/DBNAME?useUnicode=true characterEncoding=utf8
name: DBNAME
username: USERNAME
password: PWD
你必须改变:
DBNAME
USERNAME
PWD
不要忘记改变生产
src/main/resources/config/application-prod
url中的和localhost
:jdbc:mysql:// localhost
:3306到你的网址
答案 3 :(得分:0)
datasource:
driver-class-name: com.mysql.jdbc.jdbc2.optional.MysqlDataSource
url: jdbc:mysql://database hosting address:3306/database Name?useUnicode=true characterEncoding=utf8
name: database Name
username: database user name
password: and put here database user password