spring boot运行报错
springboot 版本 2.0.6
配置文件
server:
port: 10086
eureka:
client:
register-with-eureka: false
fetch-registry: false
service-url:
defaultZone: http://127.0.0.1:${server.port}/eureka/
启动类
@SpringBootApplication
@EnableEurekaServer
public class EurekaServer {
public static void main(String[] args) {
SpringApplication.run(EurekaServer.class, args);
}
}
父工程依赖
org.springframework.cloud
spring-cloud-dependencies
Finchley.SR4
pom
import
依赖
org.springframework.cloud
spring-cloud-starter-netflix-eureka-server
运行结果
Error starting ApplicationContext. To display the conditions report re-run your application with ‘debug’ enabled.
2019-09-07 09:36:32.749 ERROR 4400 — [ main] 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
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).
Process finished with exit code 1
网上查找资料说是启动springboot必须引入数据源,,,,以前也做过发送短信的微服务,没引入数据源,这个问题现在不明确,,以前的springboot是1.6的,,,还有网上说的在注解加上(exclude = DataSourceAutoConfiguration.class),问题依然存在
解决问题:
引入数据源
#spring:
datasource:
type: com.alibaba.druid.pool.DruidDataSource
#MySQL配置
driverClassName: com.mysql.jdbc.Driver
url: jdbc:mysql://localhost:3306/***?useUnicode=true&characterEncoding=UTF-8&useSSL=false
username: root
password: root
运行后报错
java.lang.TypeNotPresentException: Type javax.xml.bind.JAXBContext not present
因为JAXB-API是java ee的一部分,在jdk9中没有在默认的类路径中;
java ee api在jdk中还是存在的,默认没有加载而已,jdk9中引入了模块的概念,可以使用
模块命令–add-modules java.xml.bind引入jaxb-api;
(别人的,自己还看不懂)
地址::https://blog.youkuaiyun.com/qq_15807167/article/details/79346607
在pom文件引入
javax.xml.bind
jaxb-api
2.3.0
com.sun.xml.bind
jaxb-impl
2.3.0
org.glassfish.jaxb
jaxb-runtime
2.3.0
javax.activation
activation
1.1.1
问题解决
求大神指点 问题解决了但还是不懂问题所在
1.springboot启动必须引入数据源么?还是版本不同不同的配置?
2.只是简单的启动不需要数据库的。。。。那些依赖是干什么的