我正在服务器中开发 Spring Boot,并在前端使用 MySQL 进行 react 。
当我启动应用程序时,出现以下错误。
对于这个问题有什么指示吗?
<小时/>应用程序无法启动
<小时/>描述:
配置数据源失败:未指定“url”属性,无法配置嵌入数据源。
原因:无法确定合适的驱动程序类
行动:
考虑以下因素: 如果您想要嵌入式数据库(H2、HSQL 或 Derby),请将其放在类路径中。 如果您有要从特定配置文件加载的数据库设置,您可能需要激活它(当前没有 Activity 配置文件)。
进程已完成,退出代码为 1
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>
<groupId>fr.alexisvachard</groupId>
<artifactId>authentication-poc</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>authentication-poc</name>
<description>JWT Authentication poc</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.3.RELEASE</version>
<relativePath/>
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<jjwt.version>0.9.1</jjwt.version>
<swagger.version>2.9.2</swagger.version>
<swagger-ui.version>2.9.2</swagger-ui.version>
<aerogear-otp-java.version>1.0.0</aerogear-otp-java.version>
<zxing-core.version>3.3.3</zxing-core.version>
<zxing-javase.version>3.3.3</zxing-javase.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-freemarker</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
<version>${jjwt.version}</version>
</dependency>
<dependency>
<groupId>com.warrenstrange</groupId>
<artifactId>googleauth</artifactId>
<version>1.2.0</version>
</dependency>
<dependency>
<groupId>com.google.zxing</groupId>
<artifactId>core</artifactId>
<version>${zxing-core.version}</version>
</dependency>
<dependency>
<groupId>com.google.zxing</groupId>
<artifactId>javase</artifactId>
<version>${zxing-javase.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>${swagger.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>${swagger-ui.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>build-info</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
应用程序-dev.properties
#-Dspring.profiles.active=dev
### SERVER PROPERTIES
server.address=localhost
server.port=8080
### SPRING DATASOURCE PROPERTIES
spring.datasource.url=jdbc:mysql://localhost:3306/blog
spring.datasource.username=root
spring.datasource.password=123
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
### HIBERNATE PROPERTIES
spring.jpa.database-platform = org.hibernate.dialect.MySQL5Dialect
spring.jpa.generate-ddl=true
spring.jpa.hibernate.ddl-auto = update
### JACKSON PROPERTIES
spring.jackson.serialization.WRITE_DATES_AS_TIMESTAMPS=false
spring.jackson.date-format=dd-MM-yyyy
### LOG PROPERTIES
logging.level.fr.alexisvachard.authenticationpoc=TRACE
logging.file=authentication-poc.log
### APPLICATION PROPERTIES
fr.alexisvachard.authentication-poc.app.front.host=http://localhost:3000
fr.alexisvachard.authentication-poc.jwt.secret=
fr.alexisvachard.authentication-poc.jwt.expirationInMs=604800000
fr.alexisvachard.authentication-poc.jwt.rememberMeExpirationInMs=2592000000
fr.alexisvachard.authentication-poc.cors.maxAge=3600
fr.alexisvachard.authentication-poc.email.from=
fr.alexisvachard.authentication-poc.email.template-base-package=/mailTemplate
### EMAIL PROPERTIES
spring.mail.host=
spring.mail.username=
spring.mail.password=
spring.mail.properties.mail.transport.protocol=
spring.mail.properties.mail.smtp.port=
spring.mail.properties.mail.smtp.auth=
spring.mail.properties.mail.smtp.starttls.enable=
spring.mail.properties.mail.smtp.starttls.required=
spring.mail.properties.mail.smtp.ssl.trust=
spring.mail.default-encoding=UTF-8
spring.mail.port=
## ACTUATOR SETTINGS
management.endpoints.enabled-by-default=false
management.endpoint.health.enabled=true
management.endpoint.httptrace.enabled=true
management.endpoint.metrics.enabled=true
management.endpoints.web.base-path=/manage
management.endpoint.health.roles=ROLE_ADMIN
management.endpoint.health.show-details=when_authorized
management.endpoints.web.cors.allowed-origins=*
management.endpoints.web.cors.max-age=3600s
management.endpoints.web.cors.allowed-headers=*
management.endpoints.web.cors.allowed-methods=GET
management.endpoints.web.exposure.include=health, httptrace, metrics
应用程序-prod.properties
#-Dspring.profiles.active=prod
### SERVER PROPERTIES
server.address=localhost
server.port=8080
### SPRING DATASOURCE PROPERTIES
spring.datasource.url=jdbc:mysql://localhost:3306/blog
spring.datasource.username=root
spring.datasource.password=123
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
### HIBERNATE PROPERTIES
spring.jpa.database-platform = org.hibernate.dialect.MySQL5Dialect
spring.jpa.generate-ddl=true
spring.jpa.hibernate.ddl-auto = update
### JACKSON PROPERTIES
spring.jackson.serialization.WRITE_DATES_AS_TIMESTAMPS=false
spring.jackson.date-format=dd-MM-yyyy
### LOG PROPERTIES
logging.level.fr.alexisvachard.authenticationpoc=TRACE
logging.file=authentication-poc.log
### APPLICATION PROPERTIES
fr.alexisvachard.authentication-poc.app.front.host=http://localhost:3000
fr.alexisvachard.authentication-poc.jwt.secret=
fr.alexisvachard.authentication-poc.jwt.expirationInMs=604800000
fr.alexisvachard.authentication-poc.jwt.rememberMeExpirationInMs=2592000000
fr.alexisvachard.authentication-poc.cors.maxAge=3600
fr.alexisvachard.authentication-poc.email.from=
fr.alexisvachard.authentication-poc.email.template-base-package=/mailTemplate
### EMAIL PROPERTIES
spring.mail.host=
spring.mail.username=
spring.mail.password=
spring.mail.properties.mail.transport.protocol=
spring.mail.properties.mail.smtp.port=
spring.mail.properties.mail.smtp.auth=
spring.mail.properties.mail.smtp.starttls.enable=
spring.mail.properties.mail.smtp.starttls.required=
spring.mail.properties.mail.smtp.ssl.trust=
spring.mail.default-encoding=UTF-8
spring.mail.port=
## ACTUATOR SETTINGS
management.endpoints.enabled-by-default=false
management.endpoint.health.enabled=true
management.endpoint.httptrace.enabled=true
management.endpoint.metrics.enabled=true
management.endpoints.web.base-path=/manage
management.endpoint.health.roles=ROLE_ADMIN
management.endpoint.health.show-details=when_authorized
management.endpoints.web.cors.allowed-origins=*
management.endpoints.web.cors.max-age=3600s
management.endpoints.web.cors.allowed-headers=*
management.endpoints.web.cors.allowed-methods=GET
management.endpoints.web.exposure.include=health, httptrace, metrics
最佳答案
您使用什么命令来运行该应用程序?
我注意到您有两个配置文件:dev 和 prod。
如果您在没有配置文件的情况下运行应用程序,Spring Boot 会“查找”默认值,并且似乎没有默认属性文件。
关于java - 数据源: 'url' attribute is not specified and no embedded datasource could be configured,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55813789/