本文主要是介绍FExplorer java_Java_Explorer,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
Java_Explorer 提出了问题 · 2020-08-23
搭建fabric kafka集群,3个order、3个zookeeper、4个kafka、2个peer。
peer0创建channel,安装并初始化chaincode成功,但是在peer1上执行下面命令:peer chaincode invoke --tls --cafile $ORDERER_CA -C mychannel -n mycc -c '{"Args":["invoke","a","b","20"]}'
报错如下:Error: endorsement failure during invoke. response: status:500 message:"make sure the chaincode mycc has been successfully instantiated and try again: chaincode mycc not found"
在peer0上执行是没有问题的。
尝试在peer1上创建channel,报错如下:Error: timeout waiting for channel creation
请问该如何解决呢?
搭建fabric kafka集群,3个order、3个zookeeper、4个kafka、2个peer。peer0创建channel,安装并初始化chaincode成功,但是在peer1上执行下面命令:
关注 1回答 0
Java_Explorer 提出了问题 · 2020-08-03
搭建fabric集群,版本1.4.8,采用solo模式的4+1的架构:1 Order,4 Peer,启动报错如下:peer0.org1.example.com | 2020-08-03 02:03:55.368 UTC [core.comm] ServerHandshake -> ERRO 0d5 TLS handshake failed with error remote error: tls: bad certificate server=PeerServer remoteaddress=192.168.133.113:59870
peer0.org1.example.com | 2020-08-03 02:03:56.368 UTC [core.comm] ServerHandshake -> ERRO 0d6 TLS handshake failed with error remote error: tls: bad certificate server=PeerServer remoteaddress=192.168.133.113:59872
peer0.org1.example.com | 2020-08-03 02:03:58.273 UTC [core.comm] ServerHandshake -> ERRO 0d7 TLS handshake failed with error remote error: tls: bad certificate server=PeerServer remoteaddress=192.168.133.113:59874
peer0.org1.example.com | 2020-08-03 02:04:19.991 UTC [gossip.discovery] func1 -> WARN 0d8 Could not connect to Endpoint: peer1.org1.example.com:7051, InternalEndpoint: peer1.org1.example.com:7051, PKI-ID: , Metadata: : context deadline exceeded
peer0.org1.example.com | 2020-08-03 02:04:23.372 UTC [core.comm] ServerHandshake -> ERRO 0d9 TLS handshake failed with error remote error: tls: bad certificate server=PeerServer remoteaddress=192.168.133.113:59876
peer0.org1.example.com | 2020-08-03 02:04:24.374 UTC [core.comm] ServerHandshake -> ERRO 0da TLS handshake failed with error remote error: tls: bad certificate server=PeerServer remoteaddress=192.168.133.113:59878
peer0.org1.example.com | 2020-08-03 02:04:25.811 UTC [core.comm] ServerHandshake -> ERRO 0db TLS handshake failed with error remote error: tls: bad certificate server=PeerServer remoteaddress=192.168.133.113:59880
这是什么原因,如何解决?
搭建fabric集群,版本1.4.8,采用solo模式的4+1的架构:1 Order,4 Peer,启动报错如下: {代码...} 这是什么原因,如何解决?
关注 2回答 1
Java_Explorer 赞了回答 · 2019-08-31
因为commons-dbcp的声明被覆盖了。
你理解的前面的覆盖后面其实是间接依赖的原则。
A -> Y(1.0),B -> Y(2.0),Y(1.0)和Y(2.0)的依赖路径长度相同,如果A的声明在B之前,那么Y(1.0)会被解析使用。
因为commons-dbcp的声明被覆盖了。你理解的前面的覆盖后面其实是间接依赖的原则。 A -> Y(1.0),B -> Y(2.0),Y(1.0)和Y(2.0)的依赖路径长度相同,如果A的声明在B之前,那么Y(1.0)会被解析使用。
关注 2回答 1
Java_Explorer 提出了问题 · 2019-08-29
Maven项目引入两个jar包,groupId和artifactId相同,version不同。
commons-dbcp
commons-dbcp
1.4
commons-dbcp
commons-dbcp
1.2
根据Maven的依赖规则,应该是前面覆盖后面的,可是为什么最终依赖的是1.2,而不是1.4?
Maven项目引入两个jar包,groupId和artifactId相同,version不同。 {代码...} 根据Maven的依赖规则,应该是前面覆盖后面的,可是为什么最终依赖的是1.2,而不是1.4?
关注 2回答 1
Java_Explorer 回答了问题 · 2019-07-25
覆盖索引,如果加个字段f_4就不会走索引了。
覆盖索引,如果加个字段f_4就不会走索引了。
关注 2回答 2
Java_Explorer 提出了问题 · 2019-07-25
建表语句:CREATE TABLE `t_1` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`f_1` varchar(255) DEFAULT NULL,
`f_2` varchar(255) DEFAULT NULL,
`f_3` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `index_fh` (`f_1`,`f_2`,`f_3`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
索引index_fh是f_1、f-2、f_3三个字段创建的联合索引。
根据最左匹配原则,select * from abcd where f_1 = '1';
select * from abcd where f_1 = '1' and f_2 = '1';
select * from abcd where f_1 = '1' and f_2 = '1' and f_3 = '1';
上面三个sql语句会使用索引index_fh。
但是select * from abcd where f_2 = '1';
select * from abcd where f_3 = '1';
select * from abcd where f_2 = '1' and f_3 = '1';
应该不会使用索引,可是使用explain查看查询计划,仍然使用了索引。+------+-------------+-------+-------+---------------+----------+---------+------+------+--------------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+------+-------------+-------+-------+---------------+----------+---------+------+------+--------------------------+
| 1 | SIMPLE | t_1 | index | NULL | index_fh | 2304 | NULL | 1 | Using where; Using index |
+------+-------------+-------+-------+---------------+----------+---------+------+------+--------------------------+
建表语句:CREATE TABLE `t_2` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`f_1` varchar(255) DEFAULT NULL,
`f_2` varchar(255) DEFAULT NULL,
`f_3` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `index_fh` (`f_2`,`f_3`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
建表语句和上面基本相同,只是索引使用了f_2、f_3两个字段,此时查询语句select * from t_2 where f_3 = '1';
查看查询计划+------+-------------+-------+------+---------------+------+---------+------+------+-------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+------+-------------+-------+------+---------------+------+---------+------+------+-------------+
| 1 | SIMPLE | t_2 | ALL | NULL | NULL | NULL | NULL | 4 | Using where |
+------+-------------+-------+------+---------------+------+---------+------+------+-------------+
没有使用索引。
为什么select * from t_2 where f_3 = '1';在两个表中都不符合最左匹配原则,查询时一个使用了索引,一个没使用索引?
建表语句: {代码...} 索引index_fh是f_1、f-2、f_3三个字段创建的联合索引。 根据最左匹配原则, {代码...} 上面三个sql语句会使用索引index_fh。但是 {代码...} 应该不会使用索引,可是使用explain查看查询计划,仍然使用了索引。 {代码...} 建表语句: {代码...} ...显示全部
关注 2回答 2
Java_Explorer 关注了用户 · 2019-07-18
mercyblitz@mercyblitz
小马哥,Java 劝退师,《Spring Boot 编程思想》作者,Apache 和 Spring Cloud 等知名开源架构成员,点击查看详情。(交流QQ群:719291662)
小马哥,Java 劝退师,《Spring Boot 编程思想》作者,Apache 和 Spring Cloud 等知名开源架构成员,点击查看详情。(交流QQ群:719291662)最新发布:Spring Boot 2.0深度实践之核心技术篇Java 微服务实践系列课堂「一入 Java 深似海 」系列课程显示全部
关注 2845
Java_Explorer 提出了问题 · 2019-06-01
在使用IDEA创建Gradle项目时,想创建多级的子模块,但是新建时只能选择第一级的父模块,而不能选择第二级的模块,怎么解决?
实际创建的目录结构:parent
|---model
|---model-common
|---model-custom
|---dao
|---service
|---web
而想要的目录结构:parent
|---model
|---model-common
|---model-custom
|---dao
|---service
|---web
这种目录结构如何创建?
在使用IDEA创建Gradle项目时,想创建多级的子模块,但是新建时只能选择第一级的父模块,而不能选择第二级的模块,怎么解决? 实际创建的目录结构: {代码...} 而想要的目录结构: {代码...} 这种目录结构如何创建?
关注 3回答 2
Java_Explorer 赞了回答 · 2019-05-29
抽象类org.apache.ibatis.type.BaseTypeHandler的几个getResult()方法是public的, 你重新一下这几个方法不就好了吗?
举个例子:@Override
public T getResult(ResultSet rs, String columnName) throws SQLException {
T result;
try {
result = getNullableResult(rs, columnName);
} catch (Exception e) {
throw new ResultMapException("Error attempting to get column '" + columnName + "' from result set. Cause: " + e, e);
}
return result;
}
抽象类org.apache.ibatis.type.BaseTypeHandler的几个getResult()方法是public的, 你重新一下这几个方法不就好了吗?
关注 2回答 1
Java_Explorer 提出了问题 · 2019-05-29
项目中使用MyBatis查询数据库,数据库中一个字段的值有一部分是null,想给这些null值指定一个默认值。
实现的方式是重写TypeHandler:@Override
public String getNullableResult(ResultSet rs, String columnName) throws SQLException {
String value = rs.getString(columnName);
if (value == null) {
return "姓名为空";
}
return value;
}
xml配置:
但是返回的字段仍然是null,跟踪下源码:if (rs.wasNull()) {
return null;
} else {
return result;
}
原因是BaseTypeHandler中的这块代码影响的,rs.wasNull的值为true。
如何才能使null值得字段返回指定的默认值呢?
项目中使用MyBatis查询数据库,数据库中一个字段的值有一部分是null,想给这些null值指定一个默认值。实现的方式是重写TypeHandler:
关注 2回答 1
Java_Explorer 回答了问题 · 2019-05-29
第一个问题可以用这种方式解决:List multiLinePosition = acroFields.getFieldPositions("multiLine");
int page = multiLinePosition.get(0).page;
Rectangle rectangle = multiLinePosition.get(0).position;
float left = rectangle.getLeft();
float right = rectangle.getRight();
float top = rectangle.getTop();
float bottom = rectangle.getBottom();
//BaseFont baseFont = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", false);
Font font = new Font(baseFont, 12, Font.BOLD, BaseColor.BLACK);
PdfContentByte pdfContentByte = ps.getOverContent(page);
ColumnText columnText = new ColumnText(pdfContentByte);
Rectangle r = new Rectangle(left, bottom, right, top);
columnText.setSimpleColumn(r);
//FontFactory.getFont(FontFactory.COURIER, 20, Font.BOLD, BaseColor.RED)
Chunk chunk = new Chunk("梅雪争春未肯降,骚人搁笔费评章。梅须逊雪三分白,雪却输梅一段香。");
Paragraph paragraph = new Paragraph(12, chunk);
paragraph.setSpacingBefore(16);
columnText.addText(paragraph);
// 设置字体,如果不设置添加的中文将无法显示
paragraph.setFont(font);
columnText.addElement(paragraph);
columnText.go();
第二个问题,只能用两个文本域,没办法使用一个使其自动换行。
第一个问题可以用这种方式解决: {代码...} 第二个问题,只能用两个文本域,没办法使用一个使其自动换行。
关注 6回答 6
Java_Explorer 回答了问题 · 2019-05-29
使用acroFields.setFieldProperty(nameField, "textfont", baseFont, null);的方式不能加粗,因为第三个参数必须是BaseFont类型,不能是Font类型。
可以使用下面的方式加粗:BaseFont bf = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
Font font = new Font(bf, 12, Font.BOLD);
//Font font = FontFactory.getFont(FontFactory.COURIER, 20, Font.BOLD, BaseColor.RED);
AcroFields s = ps.getAcroFields();
// 设置加粗只能用这种方式
List multiLinePosition = s.getFieldPositions("name");
int page = multiLinePosition.get(0).page;
Rectangle rectangle = multiLinePosition.get(0).position;
float left = rectangle.getLeft();
float right = rectangle.getRight();
float top = rectangle.getTop();
float bottom = rectangle.getBottom();
PdfContentByte pdfContentByte = ps.getOverContent(page);
ColumnText columnText = new ColumnText(pdfContentByte);
Rectangle r = new Rectangle(left, bottom, right, top);
columnText.setSimpleColumn(r);
//FontFactory.getFont(FontFactory.COURIER, 20, Font.BOLD, BaseColor.RED)
Chunk chunk = new Chunk("在路上");
Paragraph paragraph = new Paragraph(12, chunk);
//paragraph.setSpacingBefore(16);
columnText.addText(paragraph);
// 设置字体,如果不设置添加的中文将无法显示
paragraph.setFont(font);
columnText.addElement(paragraph);
columnText.go();
这种方式比较笨重,但是暂时未找到好的方式。
使用acroFields.setFieldProperty(nameField, "textfont", baseFont, null);的方式不能加粗,因为第三个参数必须是BaseFont类型,不能是Font类型。可以使用下面的方式加粗:显示全部
关注 1回答 1
Java_Explorer 提出了问题 · 2019-04-26
最近在做的项目中使用itext对pdf文件进行操作,使用adobe acrobat在pdf上添加文本域,并在文本域中填充值,使用的是acroFields.setField(key, value)。
现在需要对文本域中填充的值设置样式,使用BaseFont baseFont = BaseFont.createFont("SIMSUN.TTF", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
acroFields.setFieldProperty(nameField, "textfont", baseFont, null);
设置字体后,还需要对字体加粗,该怎么设置?
最近在做的项目中使用itext对pdf文件进行操作,使用adobe acrobat在pdf上添加文本域,并在文本域中填充值,使用的是acroFields.setField(key, value)。现在需要对文本域中填充的值设置样式,使用
关注 1回答 1
Java_Explorer 回答了问题 · 2019-02-20
导致这个问题的原因是公共模块的Mapper类和模块B的Mapper类包名不一样。
只需要把mybatis-plus.mapper-locations=classpath:mapper/*Mapper.xml
修改为mybatis-plus.mapper-locations=classpath*:mapper/*Mapper.xml
就可以了。
导致这个问题的原因是公共模块的Mapper类和模块B的Mapper类包名不一样。只需要把 {代码...} 修改为 {代码...} 就可以了。
关注 1回答 1
Java_Explorer 提出了问题 · 2019-02-19
项目中使用了mybatis,提取了公共模块。公共模块包含Mapper.java和Mapper.xml,其他模块会引入这个公共模块,如模块A和模块B。模块A引入公共模块没问题,模块B引入报错:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.xxxx.esign.mapper.EsignAuthMapper.findAll
at com.baomidou.mybatisplus.core.override.PageMapperMethod$SqlCommand.(PageMapperMethod.java:261)
at com.baomidou.mybatisplus.core.override.PageMapperMethod.(PageMapperMethod.java:58)
at com.baomidou.mybatisplus.core.override.PageMapperProxy.cachedMapperMethod(PageMapperProxy.java:70)
at com.baomidou.mybatisplus.core.override.PageMapperProxy.invoke(PageMapperProxy.java:63)
at com.sun.proxy.$Proxy152.findAll(Unknown Source)
at com.xxxx.esign.service.impl.EsignAuthServiceImpl.findAll(EsignAuthServiceImpl.java:86)
at com.xxxx.esign.controller.business.EsignController.getContractByContractIdOrIdentNo(EsignController.java:180)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
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:963)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:861)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:635)
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 org.springframework.boot.web.filter.ApplicationContextHeaderFilter.doFilterInternal(ApplicationContextHeaderFilter.java:55)
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.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:61)
at org.apache.shiro.web.servlet.AdviceFilter.executeChain(AdviceFilter.java:108)
at org.apache.shiro.web.servlet.AdviceFilter.doFilterInternal(AdviceFilter.java:137)
at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:66)
at org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449)
at org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365)
at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)
at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83)
at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:387)
at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362)
at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.boot.actuate.trace.WebRequestTraceFilter.doFilterInternal(WebRequestTraceFilter.java:110)
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.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:105)
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.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.springframework.boot.actuate.autoconfigure.MetricsFilter.doFilterInternal(MetricsFilter.java:106)
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:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:478)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:80)
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:799)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:861)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1455)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
这个是什么原因导致的?如果Mapper.java和Mapper.xml无法映射,模块A应该也报错啊,现在是模块A正常,模块B有问题。相关的配置都配置了,求指教!
报错信息中有shiro的相关信息,是不是和shiro有关呢?模块A没有引入shiro,模块B用到了shiro。
项目中使用了mybatis,提取了公共模块。公共模块包含Mapper.java和Mapper.xml,其他模块会引入这个公共模块,如模块A和模块B。模块A引入公共模块没问题,模块B引入报错:
关注 1回答 1
Java_Explorer 提出了问题 · 2019-01-09
使用acrobat编辑pdf文件,在pdf文件中添加一个多行的文本域。
然后使用itext对多行文本域填充,怎么设置填充内容的间距?
另外,如果我要填充的内容可能跨行了,如图,这样怎么编辑成一个文本域?
如果是两个文本域,肯定就是两个域名(如name1和name2),填充的时候需要把填充的内容分成两半,分别填充。这个肯定不合理。
怎么用一个文本域呢?
另外,如果我要填充的内容可能跨行了,如图,这样怎么编辑成一个文本域?如果是两个文本域,肯定就是两个域名(如name1和name2),填充的时候需要把填充的内容分成两半,分别填充。这个肯定不合理。怎么用一个文本域呢?
关注 6回答 6
Java_Explorer 提出了问题 · 2018-10-24
public interface UserRepository extends MongoRepository {
User findByUsername(String username);
}
上面代码使用了Spring JPA的功能,根据姓名查找用户,但是数据库里根据姓名zong能查询出来多条数据,而findByUsername方法的返回值是User,不是List,此时预想的结果应该是报错,但是程序并没有报错,而是返回了多条数据的第一条。
请问这是什么原因,为什么没报错?
上面代码使用了Spring JPA的功能,根据姓名查找用户,但是数据库里根据姓名zong能查询出来多条数据,而findByUsername方法的返回值是User,不是List,此时预想的结果应该是报错,但是程序并没有报错,而是返回了多条数据的第一条。显示全部
关注 2回答 1
Java_Explorer 提出了问题 · 2018-08-07
使用sharding-jdbc进行分表,操作数据库使用的jpa,插入单条数据时没有问题:Sharding sharding = new Sharding();
sharding.setAppId("1001");
sharding.setNum(i);
shardingRepository.save(sharding);
使用for循环插入多条数据时报错:for (int i = 1; i < 10; i++) {
Sharding sharding = new Sharding();
sharding.setAppId("1001");
sharding.setNum(i);
shardingRepository.save(sharding);
}
报错信息如下:javax.persistence.EntityExistsException: A different object with the same identifier value was already associated with the session : [com.zkzong.sj.entity.Sharding#1]
这是什么原因?
使用sharding-jdbc进行分表,操作数据库使用的jpa,插入单条数据时没有问题: {代码...} 使用for循环插入多条数据时报错: {代码...} 报错信息如下: {代码...} 这是什么原因?
关注 2回答 1
Java_Explorer 赞了回答 · 2018-06-04
可以通过-all一次提交多个仓库
配置远程仓库
git remote add origin https://url
再添加一个远程仓库
git remote set-url --add origin https://url
注意这里多次添加需要用
git remote set-url --add
不然会报错:
fatal: remote origin already exists.
或者改名
git remote add otherOrigin https://url
一次提交到所有远程仓库
git push --all
注意
git pull 是 git pull (from) origin (to) master
git push 是 git push (to) origin (from) master
注意这里多次添加需要用git remote set-url --add不然会报错:fatal: remote origin already exists.或者改名git remote add otherOrigin https://url
关注 11回答 6
Java_Explorer 提出了问题 · 2018-05-15
javax.persistence.PersistenceException: org.hibernate.HibernateException: The database returned no natively generated identity value
at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:149)
at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:157)
at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:164)
at org.hibernate.internal.SessionImpl.firePersist(SessionImpl.java:789)
at org.hibernate.internal.SessionImpl.persist(SessionImpl.java:767)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:298)
at com.sun.proxy.$Proxy26.persist(Unknown Source)
at com.zkzong.sj.jpa.repository.OrderRepositoryImpl.insert(OrderRepositoryImpl.java:20)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:333)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:282)
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.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213)
at com.sun.proxy.$Proxy30.insert(Unknown Source)
at com.zkzong.sj.jpa.service.OrderServiceTest.addOrder(OrderServiceTest.java:28)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:75)
at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86)
at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:252)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:94)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:191)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
Caused by: org.hibernate.HibernateException: The database returned no natively generated identity value
at org.hibernate.id.IdentifierGeneratorHelper.getGeneratedIdentity(IdentifierGeneratorHelper.java:75)
at org.hibernate.dialect.identity.GetGeneratedKeysDelegate.executeAndExtract(GetGeneratedKeysDelegate.java:61)
at org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:42)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2919)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3490)
at org.hibernate.action.internal.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:81)
at org.hibernate.engine.spi.ActionQueue.execute(ActionQueue.java:636)
at org.hibernate.engine.spi.ActionQueue.addResolvedEntityInsertAction(ActionQueue.java:281)
at org.hibernate.engine.spi.ActionQueue.addInsertAction(ActionQueue.java:262)
at org.hibernate.engine.spi.ActionQueue.addAction(ActionQueue.java:316)
at org.hibernate.event.internal.AbstractSaveEventListener.addInsertAction(AbstractSaveEventListener.java:318)
at org.hibernate.event.internal.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:275)
at org.hibernate.event.internal.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:182)
at org.hibernate.event.internal.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:113)
at org.hibernate.jpa.event.internal.core.JpaPersistEventListener.saveWithGeneratedId(JpaPersistEventListener.java:67)
at org.hibernate.event.internal.DefaultPersistEventListener.entityIsTransient(DefaultPersistEventListener.java:189)
at org.hibernate.event.internal.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:132)
at org.hibernate.event.internal.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:58)
at org.hibernate.internal.SessionImpl.firePersist(SessionImpl.java:782)
... 50 more
在使用sharding-jdbc时报上面错误,数据库中主键已经设置成自增了。
数据库表对应的实体类配置如下:@Id
@Column(name = "order_id")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private long orderId;
现在主要有两个问题:报上面错误的原因,如何解决?
使用generate-key-column="order_id"配置时,生成的order_id为什么都是偶数?
{代码...} 在使用sharding-jdbc时报上面错误,数据库中主键已经设置成自增了。数据库表对应的实体类配置如下: {代码...} 现在主要有两个问题: 报上面错误的原因,如何解决? 使用generate-key-column="order_id"配置时,生成的order_id为什么都是偶数?显示全部
关注 1回答 0
这篇关于FExplorer java_Java_Explorer的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!