亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

我的 application.properties 文件中的屬性呈灰色

我的 application.properties 文件中的屬性呈灰色

吃雞游戲 2023-09-06 14:58:05
無法配置數據源:未指定“url”屬性,并且無法配置嵌入數據源。大家好,當我在 intelij 中運行應用程序嘗試連接到 mysql 時,出現以下錯誤2019-09-27 13:26:52.644  WARN 1084 --- [  restartedMain] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'inMemoryDatabaseShutdownExecutor' defined in class path resource [org/springframework/boot/devtools/autoconfigure/DevToolsDataSourceAutoConfiguration.class]: Unsatisfied dependency expressed through method 'inMemoryDatabaseShutdownExecutor' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Failed to determine a suitable driver class2019-09-27 13:26:52.648  INFO 1084 --- [  restartedMain] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]2019-09-27 13:26:52.671  INFO 1084 --- [  restartedMain] ConditionEvaluationReportLoggingListener : Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.2019-09-27 13:26:52.674 ERROR 1084 --- [  restartedMain] o.s.b.d.LoggingFailureAnalysisReporter   : ***************************APPLICATION FAILED TO START***************************Description:Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.Reason: Failed to determine a suitable driver class
查看完整描述

3 回答

?
有只小跳蛙

TA貢獻1824條經驗 獲得超8個贊

因此,經過深思熟慮,我決定查看一下我的資源文件夾和 application.properties 文件,結果發現資源目錄沒有標記為資源根目錄,右鍵單擊資源文件夾目錄,將鼠標懸停在“標記目錄上as并選擇資源根?

抱歉浪費了大家的時間,感謝您的所有幫助,因為我確實使用了提到的一些配置


查看完整回答
反對 回復 2023-09-06
?
哈士奇WWW

TA貢獻1799條經驗 獲得超6個贊

看起來像依賴性問題嘗試指定驅動程序的版本:


<dependency>

    <groupId>mysql</groupId>

    <artifactId>mysql-connector-java</artifactId>

    <version>8.0.17</version>

</dependency>


查看完整回答
反對 回復 2023-09-06
?
弒天下

TA貢獻1818條經驗 獲得超8個贊

您好,在您的財產文件上設置:


spring.datasource.url=jdbc:mysql://localhost:3306/invoice

spring.datasource.username=root

spring.datasource.password=password

spring.datasource.driverClassName=com.mysql.cj.jdbc.Driver

在你的 pom.xml 上


<parent>

    <groupId>org.springframework.boot</groupId>

    <artifactId>spring-boot-starter-parent</artifactId>

    <version>2.1.7.RELEASE</version>

    <relativePath/>

</parent>


<properties>

    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

    <maven.compiler.source>1.8</maven.compiler.source>

    <maven.compiler.target>1.8</maven.compiler.target>

</properties>


<dependencies>


    <dependency>

        <groupId>org.springframework.boot</groupId>

        <artifactId>spring-boot-starter</artifactId>

    </dependency>


    <dependency>

        <groupId>org.springframework.boot</groupId>

        <artifactId>spring-boot-devtools</artifactId>

        <optional>true</optional>

    </dependency>

    <dependency>

        <groupId>org.springframework.boot</groupId>

        <artifactId>spring-boot-starter-data-jpa</artifactId>

    </dependency>


    <dependency>

        <groupId>mysql</groupId>

        <artifactId>mysql-connector-java</artifactId>

        <scope>runtime</scope>

    </dependency>

    <!-- ... -->

</dependencies>


<build>

    <plugins>

        <plugin>

            <groupId>org.springframework.boot</groupId>

            <artifactId>spring-boot-maven-plugin</artifactId>

            <configuration>

                <mainClass>yourpackage.YourInitialApp</mainClass>

            </configuration>

            <executions>

                <execution>

                    <goals>

                        <goal>repackage</goal>

                    </goals>

                </execution>

            </executions>

        </plugin>

    </plugins>

</build>

我的github


查看完整回答
反對 回復 2023-09-06
  • 3 回答
  • 0 關注
  • 484 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號