解决办法有的很多种,下面的都是我亲测的,有时候发现第二次使用另一种方式也可以解决,所以内容仅供参考
1- jpa解决org.hibernate.lazyinitializationexception无法初始化代理 - 没有会话
#配置文件添加懒加载
spring.jpa.properties.hibernate.enable_lazy_load_no_trans=true
2- PageRequest类使用的时候利用新的一个对象的时候报错,所这个方法过时了,解决方法
PageRequest pageRequest = new PageRequest(int,int); //提示方法过时,就调用静态方法,不用新的对象了,看源码就知道了
PageRequest pageRequest = PageRequest.of(0, 5);
3-无法找到@EnableEurekaClient注解依赖,请参考
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.0.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<!--这里是问题所在,还是版本导致的-->
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Finchley.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!--引入依赖,注意不是服务端-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
4-java.net.ConnectException:连接被拒绝:连接解决办法
它可能不是错误,就是尤里卡不知道自己此时作为服务器呢还是服务的发布或者调用者,所以就抛异常,此时如果明确是作为服务器为替他请求提供调用或者注册,那么可以在YML或者特性文件说明,比如
eureka:
client:
register-with-eureka: false
fetch-registry: false
server:
port: 8761