首页 > 解决方案 > 尝试生成 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文件所在的位置。

标签: postgresqlspring-bootmaven

解决方案


好的,所以,这个设置资源目录不是问题。可以删除以下内容:

<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>

推荐阅读