Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/352.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 无法确定合适的jdbc url_Java_Spring Boot_Maven - Fatal编程技术网

Java 无法确定合适的jdbc url

Java 无法确定合适的jdbc url,java,spring-boot,maven,Java,Spring Boot,Maven,因此,当我运行命令“mvn clean spring boot:run”时,我得到以下错误: Description: Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured. Reason: Failed to determine suitable jdbc url Action: Consider the fol

因此,当我运行命令“mvn clean spring boot:run”时,我得到以下错误:

Description:

Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.

Reason: Failed to determine suitable jdbc url


Action:

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).
我知道这似乎是一个重复的问题,因为在StackOverflow上有类似的问题,但它们不一样。我找不到关于这一行的任何解释:

Reason: Failed to determine suitable jdbc url
我是springboot的新手,这是我第一次玩这样的游戏。 我将把pom.xml文件留在这里。 非常感谢您的帮助, 谢谢你抽出时间

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.2.2.RELEASE</version>
        <relativePath/>
    </parent>
    <groupId>pt.ulisboa.tecnico.socialsoftware</groupId>
    <artifactId>quizzes-tutor-backend</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>Quizzes Tutor Backend</name>
    <description>Tutor System for the Software Architecture Course</description>

    <packaging>jar</packaging>

    <repositories>
        <repository>
            <id>fenix-ashes-maven-repository</id>
            <url>https://fenix-ashes.ist.utl.pt/nexus/content/groups/fenix-ashes-maven-repository</url>
        </repository>
    </repositories>
    <properties>
        <java.version>11</java.version>
    </properties>

    <!-- Allows multiple properties files-->
    <profiles>
        <profile>
            <id>dev</id>
            <properties>
                <activatedProperties>dev</activatedProperties>
            </properties>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>

<!--Git Hook-->
<!--            <build>
                <plugins>
                    <plugin>
                        <groupId>org.springframework.boot</groupId>
                        <artifactId>spring-boot-maven-plugin</artifactId>
                    </plugin>

                    <plugin>
                        <groupId>io.github.phillipuniverse</groupId>
                        <artifactId>githook-maven-plugin</artifactId>
                        <version>1.0.4</version>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>install</goal>
                                </goals>
                                <configuration>
                                    <hooks>
                                        <pre-push>
                                            BRANCH=$(git rev-parse &#45;&#45;abbrev-ref HEAD)
                                            if [[ "$BRANCH" == "master" ]]; then
                                                cd backend
                                                exec mvn clean -Ptest test
                                            fi
                                        </pre-push>
                                    </hooks>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>-->

        </profile>
        <profile>
            <id>prod</id>
            <properties>
                <activatedProperties>prod</activatedProperties>
            </properties>
        </profile>
        <profile>
            <id>test</id>
            <properties>
                <activatedProperties>test</activatedProperties>
            </properties>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.springframework.boot</groupId>
                        <artifactId>spring-boot-maven-plugin</artifactId>
                    </plugin>

                    <plugin>
                        <!-- The gmavenplus plugin is used to compile Groovy code. To learn
                            more about this plugin, visit https://github.com/groovy/GMavenPlus/wiki -->
                        <groupId>org.codehaus.gmavenplus</groupId>
                        <artifactId>gmavenplus-plugin</artifactId>
                        <version>1.5</version>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>addTestSources</goal>
                                    <goal>testCompile</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>

                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <version>2.22.2</version>
                        <configuration>
                            <useFile>false</useFile>
                            <includes>
                                <include>**/*Test.java</include>
                                <include>**/*Spec.java</include>
                            </includes>
                        </configuration>
                    </plugin>

                    <plugin>
                        <groupId>org.jacoco</groupId>
                        <artifactId>jacoco-maven-plugin</artifactId>
                        <version>0.8.4</version>
                        <configuration>
                            <excludes>
                                <exclude>/static/export/*</exclude>
                            </excludes>
                        </configuration>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>prepare-agent</goal>
                                </goals>
                            </execution>
                            <execution>
                                <id>report</id>
                                <phase>test</phase>
                                <goals>
                                    <goal>report</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <version>2.2.4.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>javax.xml.bind</groupId>
            <artifactId>jaxb-api</artifactId>
            <version>2.4.0-b180830.0359</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-configuration-processor</artifactId>
            <optional>true</optional>
        </dependency>

        <!-- Dependency of spring-boot-starter-web but with more recent version without vulnerabilities -->
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>2.10.2</version>
        </dependency>

        <!-- Access Control -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-test</artifactId>
            <scope>test</scope>
        </dependency>

        <!-- Postgres -->
        <dependency>
            <groupId>org.postgresql</groupId>
            <artifactId>postgresql</artifactId>
            <scope>runtime</scope>
        </dependency>

        <!-- In memory database for tests -->
        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <version>1.4.200</version>
            <scope>test</scope>
        </dependency>

        <!-- Swagger -->
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger2</artifactId>
            <version>2.9.2</version>
        </dependency>
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger-ui</artifactId>
            <version>2.9.2</version>
        </dependency>

        <!-- Fenix -->
        <dependency>
            <groupId>org.fenixedu</groupId>
            <artifactId>feaf4j-api</artifactId>
            <version>2.3.1</version>
        </dependency>
        <dependency>
            <groupId>org.fenixedu</groupId>
            <artifactId>feaf4j-okhttp</artifactId>
            <version>2.3.1</version>
        </dependency>

        <!-- https://www.baeldung.com/spring-retry -->
        <dependency>
            <groupId>org.springframework.retry</groupId>
            <artifactId>spring-retry</artifactId>
            <version>1.2.5.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-aspects</artifactId>
        </dependency>

        <!-- For Working with Json Web Tokens (JWT) -->
        <dependency>
            <groupId>io.jsonwebtoken</groupId>
            <artifactId>jjwt-api</artifactId>
            <version>0.11.0</version>
        </dependency>
        <dependency>
            <groupId>io.jsonwebtoken</groupId>
            <artifactId>jjwt-impl</artifactId>
            <version>0.11.0</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>io.jsonwebtoken</groupId>
            <artifactId>jjwt-jackson</artifactId>
            <version>0.11.0</version>
            <scope>runtime</scope>
        </dependency>

        <!-- Import/Export -->
         <dependency>
            <groupId>jaxen</groupId>
            <artifactId>jaxen</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jdom</groupId>
            <artifactId>jdom2</artifactId>
        </dependency>
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>2.6</version>
        </dependency>

        <!-- Spock testing framework -->
        <dependency>
            <groupId>org.spockframework</groupId>
            <artifactId>spock-spring</artifactId>
            <version>1.3-groovy-2.5</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.spockframework</groupId>
            <artifactId>spock-core</artifactId>
            <version>1.3-groovy-2.5</version>
            <scope>test</scope>
        </dependency>

        <!-- Specific Groovy version rather than the one specified by spock-core -->
        <dependency>
            <groupId>org.codehaus.groovy</groupId>
            <artifactId>groovy-all</artifactId>
            <version>2.4.15</version>
        </dependency>

        <!-- Enables mocking of classes without default constructor (together with CGLIB) -->
        <dependency>
            <groupId>org.objenesis</groupId>
            <artifactId>objenesis</artifactId>
            <version>2.6</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
</project>

如果您使用的是springboot数据jpa,请在属性中使用“jdbcUrl”:

spring.datasource.jdbcUrl=jdbc:mysql://127.0.0.1:3306/database
spring.datasource.url=jdbc:mysql://127.0.0.1:3306/database

如果您使用的是springboot+mybatis,请在属性中使用“url”:

spring.datasource.jdbcUrl=jdbc:mysql://127.0.0.1:3306/database
spring.datasource.url=jdbc:mysql://127.0.0.1:3306/database

根据您的pom文件,我认为您正在使用H2(内存数据库)进行测试,并使用postgres进行真正的应用程序;由于您正在尝试运行应用程序,因此需要使用spring属性在属性文件中指定数据库的url,例如:spring.datasource.url=jdbc:postgresql://here_your_url:5432/here_your_db […]spring.datasource.username=here\u您的用户名[…]spring.datasource.password=here\u您的密码[…]我第一次玩这种东西时,请始终遵守正确的安全程序(PPE不是开玩笑的)。在新手见面之前,一切都很有趣。