1.Closing JPA EntityManagerFactory for persistence unit 'default'錯誤導致springboot啟動后終止
------------------->
2019-01-22 17:18:34.941 INFO 42978 --- [ Thread-13] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
2019-01-22 17:18:34.945 INFO 42978 --- [ Thread-13] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated...
2019-01-22 17:18:35.181 INFO 42978 --- [ Thread-13] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown completed.
解決辦法
在依賴中添加spring-boot-starter-web
例如Gradle在build.gradle中添加
implementation 'org.springframework.boot:spring-boot-starter-web'
問題解決
<------------------- 2019.1.22
2.Gradle加載依賴很慢,換成國內源
--------------->
repositories {
//使用國內源下載依賴
maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
mavenCentral()
}
替換之后重新Gradle下
<----------------2019-01-23
3.Gradle加載出錯,錯誤如下
startup failed:
build file '/Users/cuifuan/workspaces/springcloud-tools/tools-eureka/build.gradle': 4: all buildscript {} blocks must appear before any plugins {} blocks in the script
See https://docs.gradle.org/5.0/userguide/plugins.html#sec:plugins_block for information on the plugins {} block
@ line 4, column 1.
buildscript {
^
1 error
Open File
經過一番排查
//刪去下面代碼,如果存在,我也不知道為什么
plugins {
id 'java'
}
4.feign依賴不存在
feign 聲明式調用
Feign makes writing java http clients easier
之前安裝依賴
dependencies{
compile "org.springframework.cloud:spring-cloud-starter-feign"
compile "org.springframework.cloud:spring-cloud-starter-eureka"
}
springboot2.0之后
dependencies {
implementation "org.springframework.cloud:spring-cloud-starter-openfeign"
implementation 'org.springframework.cloud:spring-cloud-starter-eureka-server'
}
5. com.netflix.client.ClientException: Load balancer does not have available server for client: sp
build.gradle
dependencies {
implementation "org.springframework.cloud:spring-cloud-starter-openfeign"
//應是eureka-client
implementation 'org.springframework.cloud:spring-cloud-starter-netflix-eureka-client'
}
6.解決報錯 javax.persistence.TransactionRequiredException: Executing an update/delete query
運行報錯原因:少了一個注解:@Transactional : 要求開啟事物管理