Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/kotlin/3.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
Spring boot 未能配置数据源:';url';属性未指定_Spring Boot_Kotlin - Fatal编程技术网

Spring boot 未能配置数据源:';url';属性未指定

Spring boot 未能配置数据源:';url';属性未指定,spring-boot,kotlin,Spring Boot,Kotlin,我是科特林的新秀。 应用程序启动时出现错误。 在Stackoverflow的其他答案中,我一直在寻找各种解决方案 但没有答案就没有解决办法 *************************** APPLICATION FAILED TO START *************************** Description: Failed to configure a DataSource: 'url' attribute is not specified and no embedded

我是科特林的新秀。 应用程序启动时出现错误。 在Stackoverflow的其他答案中,我一直在寻找各种解决方案

但没有答案就没有解决办法

***************************
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
我的
application.properties
配置如下

spring.datasource.url=jdbc:mysql://localhost/db_name
spring.datasource.username=db_user
spring.datasource.password=db_pass
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
    id("org.springframework.boot") version "2.2.0.RELEASE"
    id("io.spring.dependency-management") version "1.0.8.RELEASE"
    war
    kotlin("jvm") version "1.3.50"
    kotlin("plugin.spring") version "1.3.50"
    kotlin("plugin.jpa") version "1.3.50"
}
group = "jp.co.blowfish.springboot"
version = "0.0.1-SNAPSHOT"
java.sourceCompatibility = JavaVersion.VERSION_1_8
val developmentOnly by configurations.creating
configurations {
    runtimeClasspath {
        extendsFrom(developmentOnly)
    }
}
repositories {
    mavenCentral()
}
dependencies {
    implementation("org.springframework.boot:spring-boot-starter-data-jpa")
    implementation("org.springframework.boot:spring-boot-starter-thymeleaf")
    implementation("org.springframework.boot:spring-boot-starter-web")
    implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
    implementation("org.jetbrains.kotlin:kotlin-reflect")
    implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
    developmentOnly("org.springframework.boot:spring-boot-devtools")
    runtimeOnly("mysql:mysql-connector-java")
    providedRuntime("org.springframework.boot:spring-boot-starter-tomcat")
    testImplementation("org.springframework.boot:spring-boot-starter-test") {
        exclude(group = "org.junit.vintage", module = "junit-vintage-engine")
    }
}
tasks.withType<Test> {
    useJUnitPlatform()
}
tasks.withType<KotlinCompile> {
    kotlinOptions {
        freeCompilerArgs = listOf("-Xjsr305=strict")
        jvmTarget = "1.8"
    }
}
下面是
build.gradle.kts

spring.datasource.url=jdbc:mysql://localhost/db_name
spring.datasource.username=db_user
spring.datasource.password=db_pass
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
    id("org.springframework.boot") version "2.2.0.RELEASE"
    id("io.spring.dependency-management") version "1.0.8.RELEASE"
    war
    kotlin("jvm") version "1.3.50"
    kotlin("plugin.spring") version "1.3.50"
    kotlin("plugin.jpa") version "1.3.50"
}
group = "jp.co.blowfish.springboot"
version = "0.0.1-SNAPSHOT"
java.sourceCompatibility = JavaVersion.VERSION_1_8
val developmentOnly by configurations.creating
configurations {
    runtimeClasspath {
        extendsFrom(developmentOnly)
    }
}
repositories {
    mavenCentral()
}
dependencies {
    implementation("org.springframework.boot:spring-boot-starter-data-jpa")
    implementation("org.springframework.boot:spring-boot-starter-thymeleaf")
    implementation("org.springframework.boot:spring-boot-starter-web")
    implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
    implementation("org.jetbrains.kotlin:kotlin-reflect")
    implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
    developmentOnly("org.springframework.boot:spring-boot-devtools")
    runtimeOnly("mysql:mysql-connector-java")
    providedRuntime("org.springframework.boot:spring-boot-starter-tomcat")
    testImplementation("org.springframework.boot:spring-boot-starter-test") {
        exclude(group = "org.junit.vintage", module = "junit-vintage-engine")
    }
}
tasks.withType<Test> {
    useJUnitPlatform()
}
tasks.withType<KotlinCompile> {
    kotlinOptions {
        freeCompilerArgs = listOf("-Xjsr305=strict")
        jvmTarget = "1.8"
    }
}
import org.jetbrains.kotlin.gradle.tasks.kotlincomfile
插件{
id(“org.springframework.boot”)版本“2.2.0.RELEASE”
id(“io.spring.dependency management”)版本“1.0.8.RELEASE”
战争
kotlin(“jvm”)版本“1.3.50”
kotlin(“plugin.spring”)版本“1.3.50”
kotlin(“plugin.jpa”)版本“1.3.50”
}
group=“jp.co.blowfish.springboot”
version=“0.0.1-快照”
java.sourceCompatibility=JavaVersion.VERSION\u 1\u 8
val仅通过配置进行开发。正在创建
配置{
运行时类路径{
扩展自(仅限开发)
}
}
存储库{
mavenCentral()
}
依赖关系{
实现(“org.springframework.boot:springbootstarterdatajpa”)
实现(“org.springframework.boot:springbootstartermyleaf”)
实现(“org.springframework.boot:springbootstarterweb”)
实现(“com.fasterxml.jackson.module:jackson模块kotlin”)
实施(“org.jetbrains.kotlin:kotlin reflect”)
实现(“org.jetbrains.kotlin:kotlin-stdlib-jdk8”)
仅限开发(“org.springframework.boot:springboot开发工具”)
runtimeOnly(“mysql:mysql连接器java”)
providedRuntime(“org.springframework.boot:springbootstartertomcat”)
测试实现(“org.springframework.boot:springbootstarter测试”){
排除(group=“org.junit.vintage”,module=“junit vintage引擎”)
}
}
tasks.withType{
useJUnitPlatform()
}
tasks.withType{
科特洛普斯酒店{
freeCompilerArgs=listOf(“-Xjsr305=strict”)
jvmTarget=“1.8”
}
}

我不知道怎么回事。

它缺少Mysql的
端口
默认为
3306

  spring.datasource.url=jdbc:mysql://localhost:3306/db_name`

或者
application.properties
位于
resources
文件夹中。

它缺少Mysql的
端口默认为
3306

  spring.datasource.url=jdbc:mysql://localhost:3306/db_name`

或者
application.properties
位于
resources
文件夹中。

我按照您的说明添加了端口。但是它不起作用。我按你说的添加了端口。但是它不起作用。