postgresql - 尝试生成 Angular 客户端代码时出现“无法确定合适的驱动程序类”
问题描述
按照本教程,我尝试通过调用来创建我的 Angular 客户端:
mvn clean verify -P angular
这给了我以下错误:
Consider the following:
If you want an embedded database (H2, HSQL or Derby), please put it on the classpath.
If you have database settings to be loaded from a particular profile you may need to activate it (no profiles are currently active).
我想这是有道理的,因为我什至没有告诉 Spring Boot 我想使用哪个配置文件
mvn clean verify -P angular -Dspring.profiles.active=local
应该帮助,或者更确切地说是整个事情:
JDBC_DATABASE_URL=jdbc:postgresql://localhost/database;JDBC_DATABASE_USERNAME=postgres;JDBC_DATABASE_PASSWORD=root mvn clean verify -P angular -Dspring.profiles.active=local
但是,我仍然收到错误消息。
另外,我在日志中看到了这一点:
my.spring.Application: No active profile set, falling back to default profiles: default
我错过了什么?
请注意:这些是我在开发过程中使用的确切运行和环境配置。
更新:
我还添加了
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
</resources>
到pom.xml,它是application-local.properties文件所在的位置。
解决方案
好的,所以,这个设置资源目录不是问题。可以删除以下内容:
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
</resources>
问题是spring-boot-maven-plugin
必须配置的。我不知道是否有更简单的方法,但现在它有效:
我必须直接在pom.xml中设置环境变量以及插件的配置文件,但是提供了比这更好的答案。
现在我的解决方案如下所示:
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<id>pre-integration-test</id>
<goals>
<goal>start</goal>
</goals>
</execution>
<execution>
<id>post-integration-test</id>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
<configuration>
<arguments>
<argument>--server.port=${tomcat.http.port}</argument>
<!-- Set the profile like this -->
<argument>--spring.profiles.active=local</argument>
</arguments>
<!-- Added these environment variables -->
<environmentVariables>
<JDBC_DATABASE_URL>jdbc:postgresql://localhost/mydatabase</JDBC_DATABASE_URL>
<JDBC_DATABASE_USERNAME>postgres</JDBC_DATABASE_USERNAME>
<JDBC_DATABASE_PASSWORD>root</JDBC_DATABASE_PASSWORD>
</environmentVariables>
</configuration>
</plugin>
推荐阅读
- php - PHP Laravel(Shopify App)如何访问 Guzzle 响应(stdclass)数据参数
- asp.net-core - ASP.NET Identity – 非字符串用户 ID 的 UserManager 和 UserStore 问题
- django - 502 Bad Gateway - AWS EBS 上的 Dockerized Django Gunicorn NGINX
- django - 如何从 Django 的上下文中向表中添加额外的类
- python - 当应用于零时,有没有办法控制 Python 十进制量化方法?
- java - 无法识别的 VM 选项“G1ReclaimDeadHumongousObjectsAtYoungGC”
- plot - 使用 gnuplot 在球体上绘制点
- ios - 使用绝对路径生成 SonarQube 代码覆盖率报告
- python - 使用 python 3.7 查找正在运行的任务
- python - 如何使用 selenium python 在新页面(相同选项卡)中填充元素