package cc.javar.util;
/***
* 异或效验
* @author chenji
***/
public class ByteCheck {
public static runXor(String[] args) {
String zhi16="5A A5 10 10 11 00 66 66 10 10 10 00 10 19 01 00 04 03 02 00 96 65 68 6C 00 5A A5 10 10 11 00 66 66 10 10 10 00 10 19 01 00 04 03 02 00 96 65 68";
String code = checkcode(zhi16.trim);
System.out.println("code:" + code);
}
public static String checkcode(String para) {
int length = para.length() / 2;
String[] dateArr = new String[length];
for (int i = 0; i < length; i++) {
dateArr[i] = para.substring(i * 2, i * 2 + 2);
}
String code = "00";
for (int i = 0; i < dateArr.length; i++) {
code = xor(code, dateArr[i]);
}
if(code.length()<2){
code = "0"+code;
}
return code;
}
private static String xor(String strHex_X, String strHex_Y) {
// 将x、y转成二进制形式
String anotherBinary = Integer.toBinaryString(Integer.valueOf(strHex_X,
16));
String thisBinary = Integer.toBinaryString(Integer
.valueOf(strHex_Y, 16));
String result = "";
// 判断是否为8位二进制,否则左补零
if (anotherBinary.length() != 8) {
for (int i = anotherBinary.length(); i < 8; i++) {
anotherBinary = "0" + anotherBinary;
}
}
if (thisBinary.length() != 8) {
for (int i = thisBinary.length(); i < 8; i++) {
thisBinary = "0" + thisBinary;
}
}
// 异或运算
for (int i = 0; i < anotherBinary.length(); i++) {
// 如果相同位置数相同,则补0,否则补1
if (thisBinary.charAt(i) == anotherBinary.charAt(i))
result += "0";
else {
result += "1";
}
}
System.out.println(result);
return Integer.toHexString(Integer.parseInt(result, 2));
}
}
JAVA部署在TOMCAT的时候不解压WAR包
第一找到配置文件 进入tomcat/conf下拷出server.xml
然后如下 配置
<Host appBase="/www/wwwroot/项目路径" autoDeploy="true" name="项目名" unpackWARs="true" xmlNamespaceAware="false" xmlValidation="false">
<Context crossContext="true" docBase="/www/wwwroot/项目路径" path="" reloadable="true" />
</Host>
the content must be served over HTTPS 解决方案一
Mixed Content: The page at 'xxx' was loaded over HTTPS, but requested an insecure resource 'xxx'. This request has been blocked; the content must be served over HTTPS.
出现这个的情况一般就是http地址没修改,或配置CDN后出现的结果,很多清空可以通过NGINX或者其他方式解决,但是实在没办法就应用以下方案
解决办法:
页面的head中加入:
<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">
意思是自动将http的不安全请求升级为https,这个必须你确定你的可以升级的http地址都支持SSL,不然肯定报错
[Java] Lombok使用方法
官方介绍:Project Lombok is a java library that automatically plugs into your editor and build tools, spicing up your java.
Never write another getter or equals method again, with one annotation your class has a fully featured builder, Automate your logging variables, and much more.
大意:永远不要再编写另一个getter或equals方法,通过一个注释,类就有了一个功能齐全的生成器,自动化日志记录变量等。
1.Lombok的使用,介绍了几个常用的注解
@Getter / @Setter
可以作用在类上和属性上,放在类上,会对所有的非静态(non-static)属性生成Getter/Setter方法,放在属性上,会对该属性生成Getter/Setter方法。并可以指定Getter/Setter方法的访问级别。
@EqualsAndHashCode
默认情况下,会使用所有非瞬态(non-transient)和非静态(non-static)字段来生成equals和hascode方法,也可以指定具体使用哪些属性。
@ToString
生成toString方法,默认情况下,会输出类名、所有属性,属性会按照顺序输出,以逗号分割。
@NoArgsConstructor, @RequiredArgsConstructor and @AllArgsConstructor
无参构造器、部分参数构造器、全参构造器,当我们需要重载多个构造器的时候,Lombok就无能为力了。
@Data:包含@ToString, @EqualsAndHashCode, 所有属性的@Getter, 所有non-final属性的@Setter和@RequiredArgsConstructor的组合,通常情况下,基本上使用这些注解就足够了。
更多的请参见: https://projectlombok.org/features/all
直接翻译官方的
val
最后!无忧无虑的最终局部变量。
var
性情不定地!无忧无虑的局部变量。
@NonNull
或者:我学会了如何停止担心并喜欢NullPointerException。
@Cleanup
自动资源管理:close()安全地调用您的方法,没有麻烦。
@Getter/@Setter
永远不要再写public int getFoo() {return foo;}了。
@ToString
无需启动调试器即可查看您的字段:只需让lombok toString为您生成一个!
@EqualsAndHashCode
平等变得简单:从对象的字段生成hashCode和equals实现..
@NoArgsConstructor, @RequiredArgsConstructor and @AllArgsConstructor
按订单生成的构造函数:生成不带参数的构造函数,每个final / non-nullfield一个参数,或每个字段一个参数。
@Data
现在所有一起:为快捷方式@ToString,@EqualsAndHashCode, @Getter在所有领域,@Setter所有非final字段,以及@RequiredArgsConstructor!
@Value
不可变的课程变得非常容易。
@Builder
......鲍勃是你的叔叔:用于创建对象的无懈可击的花式裤子API!
@SneakyThrows
大胆抛出已检查的异常,以前没有人抛出它们!
@Synchronized
synchronized 做得对:不要暴露你的锁。
@Getter(lazy=true)
懒惰是一种美德!
@Log
船长的日志,标榜24435.7:“又是什么线?”
experimental
前往实验室:我们正在研究的新东西。
maven创建项目JDK版本默认是1.5解决方法如何解决
<build>
<finalName>Springmvc</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
</plugins>
</build>