spring boot Neo4j的异常 160C

今天在调试项目时发现使用@Transactional这个注解时会报下面这个错误

org.springframework.transaction.CannotCreateTransactionException: Could not open Neo4j Session for transaction; nested exception is org.neo4j.ogm.drivers.http.request.HttpRequestException: http://localhost:7474/db/data/transaction: Connect to localhost:7474 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect
    at org.springframework.data.neo4j.transaction.Neo4jTransactionManager.doBegin(Neo4jTransactionManager.java:199)
    at org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:373)
    at org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(TransactionAspectSupport.java:461)
    at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:277)
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:673)
    at com.xuebank.kindergartenadmin.service.impl.UserMenuServiceImpl$$EnhancerBySpringCGLIB$$2ce9ff08.updateMenuAuthorize(<generated>)
    at com.xuebank.kindergartenadmin.web.controller.handle.UserPermissionController.updateMenuAuthorize(UserPermissionController.java:150)
    at com.xuebank.kindergartenadmin.web.controller.handle.UserPermissionController$$FastClassBySpringCGLIB$$258eaa60.invoke(<generated>)
    at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:738)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
    at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:97)
    at com.xuebank.kindergartenadmin.aop.MenuAuthorizeInterceptor.doAround(MenuAuthorizeInterceptor.java:99)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:629)
    at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:618)
    at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:70)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:168)
    at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:97)
    at com.xuebank.kindergartenadmin.aop.CheckLoginInterceptor.doAround(CheckLoginInterceptor.java:88)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:629)
    at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:618)
    at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:70)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:168)
    at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:673)
    at com.xuebank.kindergartenadmin.web.controller.handle.UserPermissionController$$EnhancerBySpringCGLIB$$32caf83f.updateMenuAuthorize(<generated>)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205)
    at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:133)
    at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:97)
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827)
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738)
    at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:967)
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:901)
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
    at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:661)
    at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at com.alibaba.druid.support.http.WebStatFilter.doFilter(WebStatFilter.java:123)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:108)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:81)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.springframework.session.web.http.SessionRepositoryFilter.doFilterInternal(SessionRepositoryFilter.java:167)
    at org.springframework.session.web.http.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:80)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:504)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
    at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:803)
    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:790)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1459)
    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Unknown Source)

后来调查发现是引入了下面这个包的问题

 <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-data-neo4j</artifactId>
</dependency>
那位大神能告诉我为什么引入spring-boot-starter-data-neo4j这个包注解事务就不能用了。。。
springboot版本1.5.10
liwenkeq
Venk7 遇到了同样的问题,请问楼主解决了吗?
9 个月之前 回复

1个回答

mjfl1234
迪加雷克斯
2 天之前 回复
quxxx2009
quxxx2009 兄弟你只说了Spring Data Neo4j这个怎么用,没有说spring-boot-starter-data-neo4j和@Transactional冲突的原因
一年多之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
【Spring Boot学习】Neo4j 学习
【SDN Architecture】 A high level look of the architecture looks like: Drivers are used to connect to the database. At the moment these come in 3 variants: Embedded, HTTP and the binary protocol B...
spring boot 文件上传异常
org.springframework.web.HttpMediaTypeNotSupportedException: Content type 'multipart/form-data;boundary=----WebKitFormBoundaryRAYPKeHKTYSNdzc1;charset=UTF-8' not supported   文件上传出现的异常.   原始代码 测试报...
Restful API返回对象封装
1、Resultimport java.io.Serializable;public class Result implements Serializable { private static final long serialVersionUID = -5372450875750675775L; /** * 编码 */ private Integer code; /** * 消息 */ ...
Spring boot 事务回滚异常
spring boot 事务的使用: 可以在类上加注解: 也就是启动 类上加: @EnableTransactionManagement 事务需要回滚的方法上加注解: @Transactional 如果事务不回滚,可以手动回滚  也就是在 catch 里面加入代码完成手动回滚: TransactionAspectSupport.currentTransactionStatus(...
spring boot 全局异常
直接代码 /** * 1、新建一个Class,这里取名为GlobalDefaultExceptionHandler * 2、在class上添加注解,@ControllerAdvice; * 3、在class中添加一个方法 * 4、在方法上添加@ExcetionHandler拦截相应的异常信息; * 5、如果返回的是View -- 方法的返回值是ModelAndView; * 6、如果返回
Spring Boot配置neo4j(简单版)
图数据库的开发已经变得越来越流行,与springBoot结合也是很正常,在很早前就已经发布了相关Lib,但是当前网上的Spring Boot整合neo4j都极其复杂,也导致了本人在开发过程中耗费很长时间,顾写下这个文章帮助大众理顺neo4j整合。只需要简单六步,顺序按照编写先后顺序。 首先看整体Demo项目架构: (一)首先导包pom.xml xml version="1.0
Spring Boot中引入Neo4j图形数据库
创建节点(node),查找节点,为了好的展示效果,对关系(relation)的处理后续再说。 1、Neo4j配置 2、业务模拟 3、客户端查看
spring boot 全局异常捕捉
所有未吃掉的异常均会被其捕获 @ControllerAdvice public class GlobalExceptionProcessor {     @ResponseBody     @ExceptionHandler     public String processException(Exception e) {         System.out.println("全局异常处理器
spring boot 实战: 异常,重定向
在spring中,有两个重定向类型: 301,永久性跳转 302,暂时性跳转 默认调用302。 1.下面先通过一个简单的例子实现页面的重定向 @RequestMapping(&quot;/redirect/{code}&quot;) public RedirectView redirectView(@PathVariable(&quot;code&quot;) int code, ...
spring boot jackon反序列化异常
1.Can not deserialize instance of java.util.ArrayList out of VALUE_STRING token;检测到该字段是string,而反序列化结果应该是list 2.Illegal unquoted character ((CTRL-CHAR, code 9)): has to be escaped using backslash to be
Spring Boot全局异常捕捉
新建一个类GlobalDefaultExceptionHandler, 在class注解上@ControllerAdvice, 在方法上注解上@ExceptionHandler(value = Exception.class),具体代码如下: /** * 1.在class上添加注解@ControllerAdvice * 2.在class中添加一个方法 * 3.在方法上添加@Exce...
【五】Spring Boot之 全局异常
一、一次请求分成三个阶段,来分别进行全局的异常处理 第一阶段:在进入Controller之前,譬如请求一个不存在的地址,404错误。第二阶段:在执行@RequestMapping时,进入逻辑处理阶段前。譬如传的参数类型错误。第三阶段:以上都正常时,在controller里执行逻辑代码时出的异常。譬如NullPointerException 二、SpringBoot内置异常 处理Basi...
Spring Boot之全局异常捕捉
在一个项目中的异常我们我们都会统一进行处理的,那么如何进行统一进行处理呢? 新建一个类GlobalDefaultExceptionHandler, 在class注解上@ControllerAdvice, 在方法上注解上@ExceptionHandler(value = Exception.class),具体代码如下: com.mxh.base.GlobalDefaultExceptionH...
spring boot 全局处理异常
在spring中,可以定义一个全局异常处理handler,当有异常的时候,进行拦截处理。 import com.idss.argus.common.Constant; import com.idss.argus.common.ResponseUtil; import org.springframework.http.HttpStatus; import org.springframework...
Spring Boot全局异常捕捉!
项目中避免不了有异常! 为了用户体验,常常把异常捕获起来,展现一个友好的页面,提醒用户! 在pom.xml中: <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.a
spring boot遇到的异常1
. ____ _ __ _ _ /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ \\/ ___)| |_)| | | | | || (_| | ) ) ) ) ' |____| .__|_| |_|_| |_\__, | ...
spring boot自定义全局异常
package com.zzl.plat.api.enums;import java.util.List;import java.util.Map;import java.util.Set;import javax.validation.ConstraintViolation;import javax.validation.ConstraintViolationException;import o...
Spring Boot (七) 异常相关
全局异常的处理: 1.新建一个类,例如GlobalExceptionHandler 2.类上添加@ControllerAdvice 3.添加方法 4.方法上添加@ExceptionHandler 5.若返回为String或Json数据,添加@ResponseBody import javax.servlet.http.HttpServletRequest; import or
spring boot 遇到的异常3
[ Thread-1] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@43195e57: startup date [Thu Dec 29 13:44:26 CST 2016]; r...
Spring Boot异常统一处理
最近在学习自己搭建一个配置中心平台,准备用spring boot来搭建后台web系统,将遇到的问题在此记录。github项目地址:https://github.com/zhaikevin/confCenter,如果觉得有用,请给个star。ps:还有很多东西没有完成,欢迎感兴趣的童鞋一起来搞。我们在用ajax向服务端请求数据时,免不了会有异常。如果不进行统一处理,直接把异常信息抛到前端,界面会很不...
Neo4j 启动时异常
第一次用Neo4j,安装的时候就遇到很多问题rnrn总是启动不了,出现的异常如下。哪位大神帮忙解决一下,谢谢!rnCan't load log handler "java.util.logging.FileHandler"rnjava.io.IOException: Couldn't get lock for data/log/neo4j.%u.%g.logrnjava.io.IOException: Couldn't get lock for data/log/neo4j.%u.%g.logrn at java.util.logging.FileHandler.openFiles(FileHandler.java:389)rn at java.util.logging.FileHandler.(FileHandler.java:225)rn at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)rnrn at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructrnorAccessorImpl.java:57)rn at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingCrnonstructorAccessorImpl.java:45)rn at java.lang.reflect.Constructor.newInstance(Constructor.java:526)rn at java.lang.Class.newInstance(Class.java:379)rn at java.util.logging.LogManager$4.run(LogManager.java:809)rn at java.security.AccessController.doPrivileged(Native Method)rn at java.util.logging.LogManager.loadLoggerHandlers(LogManager.java:802)rn at java.util.logging.LogManager.initializeGlobalHandlers(LogManager.javarn:1406)rn at java.util.logging.LogManager.access$1500(LogManager.java:148)rn at java.util.logging.LogManager$RootLogger.accessCheckedHandlers(LogManarnger.java:1493)rn at java.util.logging.Logger.getHandlers(Logger.java:1350)rn at java.util.logging.Logger.log(Logger.java:612)rn at java.util.logging.Logger.doLog(Logger.java:641)rn at java.util.logging.Logger.log(Logger.java:664)rn at org.neo4j.server.logging.Logger.log(Logger.java:60)rn at org.neo4j.server.logging.Logger.info(Logger.java:91)rn at org.neo4j.server.AbstractNeoServer.createInterruptStartupTimer(AbstrarnctNeoServer.java:231)rn at org.neo4j.server.enterprise.EnterpriseNeoServer.createInterruptStarturnpTimer(EnterpriseNeoServer.java:86)rn at org.neo4j.server.AbstractNeoServer.start(AbstractNeoServer.java:155)rn at org.neo4j.server.Bootstrapper.start(Bootstrapper.java:86)rn at org.neo4j.server.Bootstrapper.main(Bootstrapper.java:49)rn16-5-27 16:47:06 org.neo4j.server.AbstractNeoServer 信息: Setting startup timeournt to: 120000ms based on -1rn16-5-27 16:47:06 org.neo4j.server.database.Database 信息: Loaded neo4j tuning prrnoperties from conf/neo4j.propertiesrn16-5-27 16:47:06 org.neo4j.server.database.Database 严重: Failed to start databarnse.rn16-5-27 16:47:06 org.neo4j.server.CommunityBootstrapper 严重:rnjava.lang.RuntimeException: org.neo4j.kernel.lifecycle.LifecycleException: Compornnent 'org.neo4j.kernel.StoreLockerLifecycleAdapter@57c18b6a' was successfully inrnitialized, but failed to start. Please see attached cause exception.rn at org.neo4j.kernel.InternalAbstractGraphDatabase.run(InternalAbstractGrrnaphDatabase.java:281)rn at org.neo4j.kernel.EmbeddedGraphDatabase.(EmbeddedGraphDatabase.jrnava:106)rn at org.neo4j.graphdb.factory.GraphDatabaseFactory$1.newDatabase(GraphDatrnabaseFactory.java:88)rn at org.neo4j.graphdb.factory.GraphDatabaseBuilder.newGraphDatabase(GraphrnDatabaseBuilder.java:207)rn at org.neo4j.server.enterprise.EnterpriseDatabase$DatabaseMode$1.createDrnatabase(EnterpriseDatabase.java:43)rn at org.neo4j.server.enterprise.EnterpriseDatabase.start(EnterpriseDatabarnse.java:79)rn at org.neo4j.server.AbstractNeoServer.start(AbstractNeoServer.java:164)rn at org.neo4j.server.Bootstrapper.start(Bootstrapper.java:86)rn at org.neo4j.server.Bootstrapper.main(Bootstrapper.java:49)rnCaused by: org.neo4j.kernel.lifecycle.LifecycleException: Component 'org.neo4j.krnernel.StoreLockerLifecycleAdapter@57c18b6a' was successfully initialized, but farniled to start. Please see attached cause exception.rn at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSurnpport.java:497)rn at org.neo4j.kernel.lifecycle.LifeSupport.start(LifeSupport.java:104)rn at org.neo4j.kernel.InternalAbstractGraphDatabase.run(InternalAbstractGrrnaphDatabase.java:259)rn ... 8 morernCaused by: org.neo4j.kernel.StoreLockException: Unable to create path for storerndir: data\graph.dbrn at org.neo4j.kernel.StoreLocker.checkLock(StoreLocker.java:75)rn at org.neo4j.kernel.StoreLockerLifecycleAdapter.start(StoreLockerLifecycrnleAdapter.java:40)rn at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSurnpport.java:491)rn ... 10 morernCaused by: java.io.IOException: Unable to create directory path [data\graph.db]rnfor Neo4j store.rn at org.neo4j.kernel.DefaultFileSystemAbstraction.mkdirs(DefaultFileSysternmAbstraction.java:107)rn at org.neo4j.kernel.StoreLocker.checkLock(StoreLocker.java:70)rn ... 12 morern16-5-27 16:47:06 org.neo4j.server.CommunityBootstrapper 严重: Failed to start Nerno Server on port [7474]rnrnC:\Users\Carro>
spring boot统一处理结果(含异常)
spring boot 统一处理结果
spring boot 字段校验异常设计
CRUD操作需要反复的校验字段是否为空,字段长度等,如果每个字段都用if语句来判断工作量大且会有遗漏。 通过使用注解,可以大大简化实体字段校验。需要在不同的层使用各种注解(@NotNull、@Valid、@ControllerAdvice)来合作完成。 本文简单介绍在保存一个module实体时,对name和projectId做非空校验,需要做哪些工作。
spring boot 启动异常找不到redis jar包
3-12 09:40:59.213[WARN ][tartStop-1][o.a.c.l.WebappClassLoaderBase ][ 180]: The web application [ROOT] appears to have started a thread named [RxIoScheduler-1 (Evictor)] but has failed to st...
spring boot中的自定义异常和异常处理器
自定义异常 你可以自定义普通的Exception,也可以自定义RuntimeException。 区别:https://www.cnblogs.com/sishuiliuyun/p/4421516.html 下面的例子比较简单,你也可以在你自定义的exception中写你的逻辑。 自定义RuntimeException: 异常处理器 @ControllerAdvice拦截异常, @Exc...
Spring Boot 打包运行 中文异常
背景介绍 使用Spring Boot定时器功能做了一个定时任务,需要调用到PHP写的一个接口,PHP代码如下: &amp;lt;?php $phone = $_GET['phone']; $name = $_GET['name']; //业务逻辑省略 ?&amp;gt; JAVA代码如下 URL url = null; url = new URL(&quot;url&quot;); HttpURLConnection ...
spring boot 集成dubbo启动异常
采用spring boot 中配置dubbo 连接注册中心(zookeeper)rnrnrnpom.xmlrnrn rn io.dubbo.springbootrn spring-boot-starter-dubborn $dubbo-spring-bootrn rnrn rn rn org.springframework.bootrn spring-boot-starter-webrn rn rn rn rn com.alibabarn dubborn 2.6.1rn rn rnrn rn rn org.apache.zookeeperrn zookeeperrn 3.5.2-alpharn rn rn rn rn com.101tecrn zkclientrn 0.7rn rnrnapplication.propertiesrnrnserver.port=8070rnspring.dubbo.application.name=providerrnspring.dubbo.registry.address=zookeeper://127.0.0.1:2181rnspring.dubbo.protocol.name=dubbornspring.dubbo.protocol.port=20880rnspring.dubbo.scan=testdubbo.test.dubbornrnrn运行异常:rnorg.springframework.beans.factory.BeanCreationException: Error creating bean with name 'nbcityimpl' defined in file [D:\work\source\sts\test\target\classes\testdubbo\test\dubbo\impl\nbcityimpl.class]: Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: org/apache/curator/framework/CuratorFrameworkFactoryrn at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:587) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]rn at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:501) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]rn at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:317) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]rn at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]rn at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]rn at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]rn at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:760) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]rn at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:869) ~[spring-context-5.0.5.RELEASE.jar:5.0.5.RELEASE]rn at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550) ~[spring-context-5.0.5.RELEASE.jar:5.0.5.RELEASE]rn at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140) ~[spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE]rn at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759) [spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE]rn at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:395) [spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE]rn at org.springframework.boot.SpringApplication.run(SpringApplication.java:327) [spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE]rn at org.springframework.boot.SpringApplication.run(SpringApplication.java:1255) [spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE]rn at org.springframework.boot.SpringApplication.run(SpringApplication.java:1243) [spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE]rn at testdubbo.test.TestApplication.main(TestApplication.java:10) [classes/:na]rnCaused by: java.lang.NoClassDefFoundError: org/apache/curator/framework/CuratorFrameworkFactoryrn at com.alibaba.dubbo.remoting.zookeeper.curator.CuratorZookeeperClient.(CuratorZookeeperClient.java:46) ~[dubbo-2.6.1.jar:2.6.1]rn at com.alibaba.dubbo.remoting.zookeeper.curator.CuratorZookeeperTransporter.connect(CuratorZookeeperTransporter.java:26) ~[dubbo-2.6.1.jar:2.6.1]rn at com.alibaba.dubbo.remoting.zookeeper.ZookeeperTransporter$Adaptive.connect(ZookeeperTransporter$Adaptive.java) ~[dubbo-2.6.1.jar:2.6.1]rn at com.alibaba.dubbo.registry.zookeeper.ZookeeperRegistry.(ZookeeperRegistry.java:69) ~[dubbo-2.6.1.jar:2.6.1]rn at com.alibaba.dubbo.registry.zookeeper.ZookeeperRegistryFactory.createRegistry(ZookeeperRegistryFactory.java:37) ~[dubbo-2.6.1.jar:2.6.1]rn at com.alibaba.dubbo.registry.support.AbstractRegistryFactory.getRegistry(AbstractRegistryFactory.java:95) ~[dubbo-2.6.1.jar:2.6.1]rn at com.alibaba.dubbo.registry.RegistryFactory$Adaptive.getRegistry(RegistryFactory$Adaptive.java) ~[dubbo-2.6.1.jar:2.6.1]rn at com.alibaba.dubbo.registry.integration.RegistryProtocol.getRegistry(RegistryProtocol.java:200) ~[dubbo-2.6.1.jar:2.6.1]rn at com.alibaba.dubbo.registry.integration.RegistryProtocol.export(RegistryProtocol.java:134) ~[dubbo-2.6.1.jar:2.6.1]rn at com.alibaba.dubbo.qos.protocol.QosProtocolWrapper.export(QosProtocolWrapper.java:54) ~[dubbo-2.6.1.jar:2.6.1]rn at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper.export(ProtocolFilterWrapper.java:91) ~[dubbo-2.6.1.jar:2.6.1]rn at com.alibaba.dubbo.rpc.protocol.ProtocolListenerWrapper.export(ProtocolListenerWrapper.java:54) ~[dubbo-2.6.1.jar:2.6.1]rn at com.alibaba.dubbo.rpc.Protocol$Adaptive.export(Protocol$Adaptive.java) ~[dubbo-2.6.1.jar:2.6.1]rn at com.alibaba.dubbo.config.ServiceConfig.doExportUrlsFor1Protocol(ServiceConfig.java:505) ~[dubbo-2.6.1.jar:2.6.1]rn at com.alibaba.dubbo.config.ServiceConfig.doExportUrls(ServiceConfig.java:357) ~[dubbo-2.6.1.jar:2.6.1]rn at com.alibaba.dubbo.config.ServiceConfig.doExport(ServiceConfig.java:316) ~[dubbo-2.6.1.jar:2.6.1]rn at com.alibaba.dubbo.config.ServiceConfig.export(ServiceConfig.java:215) ~[dubbo-2.6.1.jar:2.6.1]rn at com.alibaba.dubbo.config.spring.AnnotationBean.postProcessAfterInitialization(AnnotationBean.java:181) ~[dubbo-2.6.1.jar:2.6.1]rn at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:437) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]rn at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1706) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]rn at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:579) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]rn ... 15 common frames omittedrnCaused by: java.lang.ClassNotFoundException: org.apache.curator.framework.CuratorFrameworkFactoryrn at java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[na:1.8.0_162]rn at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_162]rn at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:338) ~[na:1.8.0_162]rn at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_162]rn ... 36 common frames omitted
Spring boot全局异常统一拦截
前言: spring boot学习以及使用也有一段时间了,平时疏于整理资料,故今日写一篇关于全局异常的资料 背景: 异常处理是为了给用户带来良好的交互体验 异常: 访问了错误的页面,或者是非法的访问导致服务器不能返回正常的数据,例如访问了不存在的页面导致404 程序代码内部的错误,在开发时期由于没有考虑周全导致的程序异常,列如常见的空指针异常(NullPointExceptio...
spring boot 服务启动 log4j日志异常
2016-07-26 15:52:01,088 main WARN Could not instantiate FastDateFormat with pattern YYYYMMddHHmmss java.lang.IllegalArgumentException: Illegal pattern component: YYYYn at org.apache.logging.log4j.core.util.datetime.FastDatePrinter.parsePattern(FastDatePrinter.java:264)n at org.apache.logging.log4j.core.util.datetime.FastDatePrinter.init(FastDatePrinter.java:124)n at org.apache.logging.log4j.core.util.datetime.FastDatePrinter.(FastDatePrinter.java:115)n at org.apache.logging.log4j.core.util.datetime.FastDateFormat.(FastDateFormat.java:100)n at org.apache.logging.log4j.core.util.datetime.FastDateFormat.(FastDateFormat.java:81)n at org.apache.logging.log4j.core.util.datetime.FastDateFormat$1.createInstance(FastDateFormat.java:61)n at org.apache.logging.log4j.core.util.datetime.FastDateFormat$1.createInstance(FastDateFormat.java:58)n at org.apache.logging.log4j.core.util.datetime.FormatCache.getInstance(FormatCache.java:82)n at org.apache.logging.log4j.core.util.datetime.FastDateFormat.getInstance(FastDateFormat.java:140)n at org.apache.logging.log4j.core.pattern.DatePatternConverter.createFormatter(DatePatternConverter.java:176)n at org.apache.logging.log4j.core.pattern.DatePatternConverter.(DatePatternConverter.java:132)n at org.apache.logging.log4j.core.pattern.DatePatternConverter.newInstance(DatePatternConverter.java:144)n at org.apache.logging.log4j.core.pattern.FileDatePatternConverter.newInstance(FileDatePatternConverter.java:49)n at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)n at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)n at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)n at java.lang.reflect.Method.invoke(Method.java:606)n at org.apache.logging.log4j.core.pattern.PatternParser.createConverter(PatternParser.java:548)n at org.apache.logging.log4j.core.pattern.PatternParser.finalizeConverter(PatternParser.java:601)n at org.apache.logging.log4j.core.pattern.PatternParser.parse(PatternParser.java:385)n at org.apache.logging.log4j.core.appender.rolling.PatternProcessor.(PatternProcessor.java:69)n at org.apache.logging.log4j.core.appender.rolling.RollingFileManager.(RollingFileManager.java:58)n at org.apache.logging.log4j.core.appender.rolling.RollingFileManager$RollingFileManagerFactory.createManager(RollingFileManager.java:326)n at org.apache.logging.log4j.core.appender.rolling.RollingFileManager$RollingFileManagerFactory.createManager(RollingFileManager.java:291)n at org.apache.logging.log4j.core.appender.AbstractManager.getManager(AbstractManager.java:71)n at org.apache.logging.log4j.core.appender.OutputStreamManager.getManager(OutputStreamManager.java:61)n at org.apache.logging.log4j.core.appender.rolling.RollingFileManager.getFileManager(RollingFileManager.java:79)n at org.apache.logging.log4j.core.appender.RollingFileAppender.createAppender(RollingFileAppender.java:193)n at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)n at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)n at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)n at java.lang.reflect.Method.invoke(Method.java:606)n at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.build(PluginBuilder.java:136)n at org.apache.logging.log4j.core.config.AbstractConfiguration.createPluginObject(AbstractConfiguration.java:813)n at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:753)n at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:745)n at org.apache.logging.log4j.core.config.AbstractConfiguration.doConfigure(AbstractConfiguration.java:389)n at org.apache.logging.log4j.core.config.AbstractConfiguration.initialize(AbstractConfiguration.java:169)n at org.apache.logging.log4j.core.config.AbstractConfiguration.start(AbstractConfiguration.java:181)n at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:446)n at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:520)n at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:536)n at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:214)n at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:146)n at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:41)n at org.apache.logging.log4j.LogManager.getContext(LogManager.java:185)n at org.apache.logging.log4j.spi.AbstractLoggerAdapter.getContext(AbstractLoggerAdapter.java:103)n at org.apache.logging.slf4j.Log4jLoggerFactory.getContext(Log4jLoggerFactory.java:43)n at org.apache.logging.log4j.spi.AbstractLoggerAdapter.getLogger(AbstractLoggerAdapter.java:42)n at org.apache.logging.slf4j.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:29)n at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:358)n at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:155)n at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:132)n at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:273)n at org.springframework.boot.SpringApplication.(SpringApplication.java:190)n at com.wjcard.ApplicationRun.main(ApplicationRun.java:25) 怀疑jar包问题 不过jar包和之前无变化 继续排查
Spring cloud spring boot spring boot admin
Spring cloud spring boot spring boot admin。spring demo,
Spring boot 数据源未配置异常
问题在使Springboot自动生成的项目框架时如果选择了数据源,比如选择了mysql,生成项目之后,启动会报一下异常:Description:Cannot determine embedded database driver class for database type NONEAction:If you want an embedded database please put a suppor
Spring boot 数据源缺失异常解决方案
问题 在使Springboot自动生成的项目框架时如果选择了数据源,比如选择了mysql,生成项目之后,启动会报一下异常: Description: Cannot determine embedded database driver class for database type NONE Action: If you want an embedded database ...
Spring Boot教程八:捕获全局异常
为了统一api的返回格式,方便前端接受返回数据,全局异常处理是个比较重要的功能,一般在项目里都会用到。 Springboot中的异常捕获通常分为三个阶段。 一:在进入Controller之前,如果请求一个不存在的地址,404错误等  /** * @ClassName: FinalExceptionHandler * @Description: 在进入Controller之前,譬如
Spring Boot 菜鸟教程 异常 集锦
集成Spring Data JPA 异常信息摘要: org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Cannot determine embedded database driver class for database type NONE. If
Spring boot 统一处理Filter异常
由于Filter异常Spring MVC无法进行统一处理,所以需要手动处理一下异常 定义一个Filter,这个Filter位于所有Filter的最前面,当其他Filter发生异常,捕获异常栈,然后转发到ErrorController @Slf4j public class ExceptionFilter implements Filter { @Override public vo...
在spring boot中如何自定义Exception异常
载着干货的老司机 下图示例: 在service的方法中进行判断年龄,参数一:message,super关键字,调用父类的message,参数二:code,均为自定义,具体方法如下: @ControllerAdvice:在于捕获controller中出现的异常 @ExceptionHandler:指定使用的异常类 @ResponseBody:返回相应的数据 完成上述工作你会神...
Spring Boot 集成bug异常汇总
Spring Boot 集成bug异常汇总Spring Boot 集成bug异常汇总mybatis plus java.lang.AbstractMethodError: nulljava.sql.SQLException: The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized Spring Boot 集成bug异常汇总 你好! 这是你...
spring boot中全局异常的定义
全局异常 import com.alibaba.fastjson.JSON; import com.ziku.msp.common_enum.ErrorCodeEnum; import com.ziku.msp.exception.BizException; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.exc...
spring boot websocket 打包 单元测试异常解决方案
最近公司项目需要使用websocket与前端通信,使用spring boot作为脚手架,在搭建框架时引入spring-boot-stater-websocket后可以正常运行,但所有单元测试都执行失败。控制台异常信息为: 18:04:02.505 [main] DEBUG org.springframework.test.context.junit4.SpringJUnit4ClassRunn...
Spring Boot : 全局异常捕捉(三)
在写 Spring Boot : 自动JSON转换和热部署(二) 时本来想把全局异常捕捉加上的,但是不知道为什么测试一直没成功.今天又看了下全局异常捕捉@ControllerAdvice 和 @ExceptionHandler 两个标签. 参考 : Spring3.2新注解@ControllerAdvice , 在spring扫描bean的时候一定要把全局异常捕捉类扫描进来,否则是不成功的.下面是反
相关热词 c# 线程结束时执行 c# kb mb 图片 c# 替换第几位字符 c#项目决定成败 c# 与matlab c# xml缩进 c#传感器基础 c#操作wps c# md5使用方法 c# 引用父窗口的组件