zoukankan      html  css  js  c++  java
  • [SrpingBoot]初步搭建springboot应用,报错:Failed to configure a DataSource: 'url' attribute is not specified and no embedd[转载]

    1 错误信息

    Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.
    无法配置DataSource:未指定'url'属性,也无法配置嵌入数据源。
    

    2 分析

    即 在应用中尚未配置datasource的一些相关属性,例如:数据源连接URL,数据库驱动,用户名,密码等

    SpringBoot的自动配置:我们只是需要提供配置文件的值,SpringBoot就会自动配置。配置在application.properties文件中。

    #访问根路径
     
    #应用名称
    spring.application.name=springboot-demo
     
    #访问端口号
    server.port=8080
     
    #编码格式
    server.tomcat.uri-encoding=utf-8
     
    #数据库相关配置
    spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
    spring.datasource.url=jdbc:mysql://localhost:3306/sql_test
    spring.datasource.username=root
    spring.datasource.password=123456
    spring.datasource.max-idle=10
    spring.datasource.max-wait=10000
    spring.datasource.min-idle=5
    spring.datasource.initial-size=5
     
    #session生命周期
    server.servlet.session.timeout=30m
    

    3 其它解决方法

    当然,也可不配置,但需要特别声明一下启动类头部声明:

    @SpringBootApplication(exclude= {DataSourceAutoConfiguration.class})
    

    4 参考文献

  • 相关阅读:
    研究下线程投递
    IOCP笔记
    线程同步之mutex和Semaphore
    线程同步之mutex和event区别
    MyStack
    unix环境高级编程 读书笔记
    binary search tree study
    技术博客地址搜集
    select收数据
    奇怪的问题
  • 原文地址:https://www.cnblogs.com/johnnyzen/p/13527048.html
Copyright © 2011-2022 走看看