错误解决
常见错误解决
常见报错解决
Spring 整合Junit4测试:
log4j:WARN No appenders could be found for logger
(org.springframework.test.context.junit4.SpringJUnit4ClassRunner).
log4j:WARN Please initialize the log4j system properly.
解决办法:在src下建新的file名为log4j.properties
然后其内如下
log4j.rootLogger=WARN, stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - %m%n
Junit4
initilizationError[Runner:JUnit4](0.00)表示可能该方法没加@Test
js使用时一定要注意每句后面加分号
jsp页面数据传递①hidden②?参数名=值
maven错误
Batch update returned unexpected row count from update [0]; actual row count: 0;
Batch update returned unexpected row count from update [0]; actual row count: 0;
expected: 1
这个异常是由于主键设置为自增长/uuid,而在我们插入记录的时候设置了ID的值导致的
Maven项目启动的时候一定要设置好tomcat7的版本,注意端口占用问题
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<!-- 可以灵活配置工程路径 -->
<path>/ssh</path>
<!-- 可以灵活配置端口号 -->
<port>8080</port>
</configuration>
</plugin>
Maven错误
[ERROR] No compiler is provided in this environment.
Perhaps you are running on a JRE rather than a JDK?
对于Java开发者来说, Installed JREs中使用jdk目录
而不适用jre目录也是最好的选择. 按下图配置
![maven报错1.PNG](https://290ff162.telegraph-image-eg9.pages.dev/file/0bf9fbde3ee68241766f7.png)
永久去除jsp报错
https://jingyan.baidu.com/article/7f766dafbb5cf34101e1d0d8.html
spring报错
注意单独配置后springmvc改了url后面重新启动项目不会更新配置,
一定要clean
Springmvc的 service经过扫描后无法xml配解注入dao接口实现类,
需要用@Resource(name=”xxx”)来注入,是因为springmvc配置为子容器,
而spring本身是父容器,且子能访问父,父不能访问子,
故由于springmvc在请求到来的时候扫描了controller作为bean,即使没注解dao属性,
但是已经将整个该类注册成bean,故之后的spring
父容器再注册也不能再注入dao进去了
是因为,系统首先加载spring父容器(application。Xml文件)
第一次注册了service整个注解(包括依赖的dao接口),然而跟springmvc无关,
相当于没注册进去springmvc容器。
然后再加载springmvc文件,当加载到dao接口属性的时候,
由于springmvc的扫描扫描bean的时候该接口属性没配置注解,导致没注入dao接口,报空指针错误。
①如果在springmvc里面再用xml注解补充dao的注入的话,会报
There is already handler of type [class com.junye.service.ItemsServiceImpl]
mapped.错误,
②即使注解和xml配置调转了都不行,仍然报同样的错误
(解释:是因为系统优先加载xml配置,然后再加载注解配置)
③单独xml配置(去掉包扫描)完全没问题,说明springmvc不能同时用注解配置和xml配置
④而对于spring本身来说却可以重复配置一样的bean进去容器,但以xml的配置为准
补充,子容器能访问父容器的内容,但是父容器不能访问子容器的内容
结论:springmvc开启扫描包扫描bean的时候。里面必须都注解注入,
不要部分属性xml配置、部分注解,springmvc不允许用注解配置和xml注册同一个bean,
而spring本身却可以,以xml为准
applicationContext里面已经声明了 service的对象bean,
又扫描service类的上面注解@Component声明为bean,
重复导致spring容器不能判断Service的成员装配哪个对象。
Xml配置优先于注解配置,加载顺序listener》filter》servlet,
而spring配置文件先加载,后加载springmvc的配置文件。
Springmvc使用必须用自己的springmvc扫描到controller注解的bean,
若是spring扫的话没用,404
struts2
注意struts整合spring时action必须设置scope=”prototype”
判断是不是为true,直接<s:if test="#parameters.select">,
不要<s:if test="#parameters.select==true">
Hibernate:Named query not known异常的一种解决方案
请注意标签<query>要定义在<class>之外<hibernate-mapping>之内
如果定义在<class>之内,就有可能报这个错误
</class>
********************************************
******************注意<query>标签位置*******
**********************************************
<query name="getTeacherNotInClasses">SQL语句</query>
<query name="getClassesByTitle">sql语句</query>
</hibernate-mapping>
1、存储json用blob类型
活动介绍[{"type":"image","content":"https://bzstatic.udinovo.com/tmp_34a994ba8130b1cec3431b941a6af9f5.jpg"},{"type":"image","content":"https://bzstatic.udinovo.com/tmp_bbd3892eba215a1d247aadef19a0f764.jpg"},{"type":"image","content":"https://bzstatic.udinovo.com/tmp_5c72371caeb39b1ae705527c49fbeacb.gif"}]
2、只要用户登入系统,一般就记录一个游客记录到user表,以ctype 客户身份. 0:游客;1:授权用户;2:品牌用户标志一下
3.、存储自定义列表可以用,;,;
4、获取长度判断char_length(an.comment)<=?
5、服务器不重用tcp解决方案https://www.cnblogs.com/aoxueshou/p/13546814.html
7、join on可以加and or条件
8、esxist用于判断有人报名的显示
9、min(delete)判断是否报过名banzhu_action_bao
10\gradlew build --refresh-dependencies
11、
12、order by xxx!=xxx
13、group by 巧用max和min筛选匹配项max(if xxxx= xx,1,0)
14、数据库中计算2点的距离,ifnull(st_distance(point(c.lat,c.lng),point(#{pagination.lat},#{pagination.lng})) * 111195,0) as pointdistance单位m https://blog.csdn.net/worilb/article/details/124976921
lat是纬度lng是经度
this AnnotationConfigServletWebServerApplicationContext
spring refresh(){
prepareRefresh->
{
initPropertySourcesStandardServletEnvironment
earlyApplicationListeners
earlyApplicationEvents
}
}
15.排序不包括同名
rank() over (order by)
Creating sort index
Your authorization verification fails, you can still continue to use the system for 5 minutes, and the system will automatically stop after 5 minutes
17 一个字段是否为null业务可以判断是否已经坐过什么,如果字段为更新时间,那么就可以一个字段同时满足是否更新和什么时候更新两个业务
雪狼框架的分配分布式唯一id可能会因为已经存在类似的id而导致堆栈溢出
七牛云测试视频https://bzstatic.udinovo.com/2313.mp4
18 自定义费用
xxx:xx;xxx,xx;
SELECT s.*,u.nick,u.gender,u.avatar,t.mode
FROM banzhu_sport s inner join banzhu_user u on u.uid = s.uid
WHERE s.uid IN (select fs.uid from banzhu_user_focus fs
inner join banzhu_user u on fs.uid = u.uid where fs.focusUid = #{pagination.uid} and fs.uid in (select focusUid from banzhu_user_focus where uid = #{pagination.uid})
and fs.uid != #{pagination.uid}
<if test="pagination.keywords">
and u.nick like "%"#{pagination.keywords}"%"
</if>
and u.uid != #{pagination.uid} )
AND s.typeId = #{pagination.map.typeId} AND s.seconds = #{pagination.map.seconds}
AND NOT EXISTS (SELECT 1 FROM banzhu_sport WHERE uid = s.uid AND typeId = s.typeId AND seconds = s.seconds AND sportCnt > s.sportCnt)
group by s.uid
select abc.*,IFNULL(max(s.sportCnt),0) as sportCnt,s.id,st.mode,s.round,s.createTime,t.mode
from
(select fs.uid,u.nick,u.gender,u.avatar from banzhu_user_focus fs
inner join banzhu_user u on fs.uid = u.uid where fs.focusUid = #{pagination.uid} and fs.uid in (select focusUid from banzhu_user_focus where uid = #{pagination.uid})
and fs.uid != #{pagination.uid}
and u.uid != #{pagination.uid} ) abc left join banzhu_sport s on s.uid = abc.uid and s.seconds = #{pagination.map.seconds} and s.typeId = #{pagination.map.typeId}
left join banzhu_sport_team st on st.id = s.teamId
group by abc.uid
mysqlsysdate()不走索引
sse客户端解析代码
怎么接收http请求response 的content-type=text/event-stream
boolean processNextEvent() throws IOException {
String id = this.lastId;
String type = null;
Buffer data = new Buffer();
while(true) {
long lineEnd = this.source.indexOfElement(CRLF);
if (lineEnd == -1L) {
return false;
}
switch(this.source.getBuffer().getByte(0L)) {
case 10:
case 13:
this.completeEvent(id, type, data);
return true;
case 100:
if (this.isKey(DATA)) {
this.parseData(data, lineEnd);
continue;
}
break;
case 101:
if (this.isKey(EVENT)) {
type = this.parseEvent(lineEnd);
continue;
}
break;
case 105:
if (this.isKey(ID)) {
id = this.parseId(lineEnd);
continue;
}
break;
case 114:
if (this.isKey(RETRY)) {
this.parseRetry(lineEnd);
continue;
}
}
this.source.skip(lineEnd);
this.skipCrAndOrLf();
}
}
update xxx set xxx-1 where xxx>0 and id = ?
表设计可以使用action_xxx来即可用到action前缀索引,又能用到action_xxx索引,还能分action类和action_xxx小类
docker日志收集
https://www.coder4.com/homs_online/ch01-architecture/micro-service-intro.html
redis集群持久化
https://help.aliyun.com/document_detail/90529.html?spm=a2c4g.11186623.6.569.1408519e9VE04k
目前要么elk efk 或者fk-elk
ps -ef |grep java |grep -w testbanzhu.jar|grep -v 'grep'|awk '{print $2}'| xargs -i{} kill -9 {}
sleep 1 && nohup java -server -jar testbanzhu.jar --server.port=8888 &