When the project is packaged: No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
可能是安装了多版本maven,与系统指定的maven不一致 导致idea没有识别出新版本的maven(需要设置默认maven,并重启生效--是个坑), 以及设置maven的Runner(指定JDK版本,如果安装了多个的话).
APR版本不兼容 An incompatible version [1.1.33] of the APR based Apache Tomcat Native library is installed, while Tomcat requires version [1.2.14]
目前Tomcat8以上推荐使用APR, 解决方法:升级该版本、或者关闭APR(Spring Boot 2以上好像会自动开启)
SH script line break problem $'\r': command not found
打开vi使用set ff=unix
MyBatisPlus采坑 org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)
原因是没有扫描到自定的xml文件,debug发现MyBatisPlus默认扫描dao层同目录下的xml文件。解决方法有两种。
1. 是把xml文件复制到dao层同一目录下,MybatisPlus会自动扫描
2. mybatis-plus.mapper-locations=classpath*:/mapper/*.xml 指定扫描路径,注意:xml是放在resource下的,放在src下目测无效
MyBatis opens the secondary cache and reports an error
缺少包:
<!--mybatis 启用ehcache 二级缓存-->
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-ehcache</artifactId>
<version>1.0.0</version>
</dependency>
MyBatisPlus enumeration class association exception
问题描述:
真是诡异的一幕, 使用@Test时,一切枚举类相关的正常, 但应用启动后,访问controller调用service时, 出现枚举类关联失败,导致插入数据库的不是枚举状态值,而是字符串,导致插入失败.初步认为是MyBatisPlus3.0.7.1默认的枚举处理器有问题
解决方式:
在properties或yml中配置mybatis-plus.configuration.default-enum-type-handler=org.apache.ibatis.type.EnumOrdinalTypeHandler 指定枚举类处理器
同时记得指定mybatis-plus.type-enums-package=com.***.enums
tip:
1. 使用MyBatisPlus关联枚举类, 只需要加@EnumValue
2. MVC枚举类与状态码的转换, 只需要使用@JsonValue和@JsonCreator
完整枚举类样例:
```java
import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import org.apache.commons.collections.map.HashedMap;
import java.util.Map;
/**
* @Author: laichengfeng
* @Description: 账号状态
* @Date: 2019/06/03 14:06
*/
public enum AccountStatus {
NO_ACTIVE(0),
NORMAL(1),
FREEZE(2);
@EnumValue
private int code;
AccountStatus(int code) {
this.code = code;
}
public static final Map<Integer, AccountStatus> map = new HashedMap();
static {
for(AccountStatus status: values()) {
map.put(status.getCode(), status);
}
}
@JsonCreator
public static AccountStatus of(int code) {
return map.get(code);
}
@JsonValue
public int getCode() {
return code;
}
}
```
git reset --hard xxx There is no git commit local code before, resulting in the loss of code, the same blood lesson (with git add, no git coomit, part of it can be restored)
https://www.cnblogs.com/hope-markup/p/6683522.html
When MyBatisPlus uses the default org.apache.ibatis.type.EnumOrdinalTypeHandler, @Test can process the enumeration class normally, but it cannot be processed when the service starts normally (3.0.7.1)
处理方式: 将MP改成3.1.1版本, 然后添加mybatis-plus.configuration.default-enum-type-handler=com.baomidou.mybatisplus.extension.handlers.EnumTypeHandler
如果在mapper.xml中需要用到枚举类转换, 以如下方式写入
<update id="updateStatusAndPasswordById">
update bal_user
set status=#{status, typeHandler=com.baomidou.mybatisplus.extension.handlers.EnumTypeHandler}, password=#{password},
<include refid="Base_Update_Time"/>
where id=#{id}
</update>
Springboot adds external jar package and packaging (external jar is not added when packaging)
https://www.cnblogs.com/bbthome/p/9230030.html
Cannot access html and jsp after springboot integrates jsp into jar package
https://blog.csdn.net/qq_26684469/article/details/81475432
Git synchronizes multiple remote warehouses
git remote -v
git remote remove origin
git remote add origin xxx
git remote set-url --add origin xxx
RSA generated key pair length is 1024 and 2048 is different [javax.crypto.BadPaddingException: Decryption error]
出现javax.crypto.BadPaddingException: Decryption error异常时,请检查RSA对应密钥对的位数以及每次加解密长度
1024位:
每次加密最大长度为117位
每次解密最大长度为128位
2048位:
每次加解密最大长度都是256位
When multiple modules use Eureka service discovery, there is a problem that remote services cannot be referenced
检查引用远程服务的类是否在@EnableXXX类的子目录中
org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type ‘org.springframework.transaction.PlatformTransactionManager’ available: expected single matching bean but found 2: transactionManager,dataSourceTransactionManager
多配置了dataSource
Set转String[]报java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to [Ljava.lang.String;
错误
Set<String> set = new HashSet<>();
String[] strsFalse = (String[]) set.toArray();
正确
String[] strsTrue = set.toArray(new String[set.size()]);
Random number generation (thread safety & high performance)
class | Thread safe | performance | JDK version |
---|---|---|---|
Random | Thread safe | low | Before 1.7 |
ThreadLocalRandom | Thread safe | high | 1.7 and after |