0%

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE generatorConfiguration
PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
"http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">

<generatorConfiguration>
<!-- windows下路径, D:\downloads\xxx.jar-->
<classPathEntry location="D:\mysql-connector-java-5.1.6.jar" />

<context id="DB2Tables" targetRuntime="MyBatis3">

<!-- 不再追加xml内容-->
<plugin type="org.mybatis.generator.plugins.UnmergeableXmlMappersPlugin" />

<commentGenerator>
<property name="suppressAllComments" value="true"/>
</commentGenerator>

<jdbcConnection driverClass="com.mysql.jdbc.Driver"
connectionURL="jdbc:mysql://127.0.0.1:3306/mall?characterEncoding=utf-8"
userId="root"
password="123456">
</jdbcConnection>

<javaTypeResolver >
<property name="forceBigDecimals" value="false" />
</javaTypeResolver>

<javaModelGenerator targetPackage="tech.xixing.qaqmall.pojo" targetProject="src/main/java">
<property name="enableSubPackages" value="true" />
<!-- <property name="trimStrings" value="true" />-->
</javaModelGenerator>

<sqlMapGenerator targetPackage="mappers" targetProject="src/main/resources">
<property name="enableSubPackages" value="true" />
</sqlMapGenerator>

<javaClientGenerator type="XMLMAPPER" targetPackage="tech.xixing.qaqmall.dao" targetProject="src/main/java">
<property name="enableSubPackages" value="true" />
</javaClientGenerator>

<!-- <table tableName="mall_order" domainObjectName="Order" enableCountByExample="false" enableDeleteByExample="false" enableSelectByExample="false" enableUpdateByExample="false"/>-->
<!-- <table tableName="mall_order_item" domainObjectName="OrderItem" enableCountByExample="false" enableDeleteByExample="false" enableSelectByExample="false" enableUpdateByExample="false"/>-->
<!-- <table tableName="mall_user" domainObjectName="User" enableCountByExample="false" enableDeleteByExample="false" enableSelectByExample="false" enableUpdateByExample="false"/>-->
<!-- <table tableName="mall_category" domainObjectName="Category" enableCountByExample="false" enableDeleteByExample="false" enableSelectByExample="false" enableUpdateByExample="false"/>-->
<!-- <table tableName="mall_product" domainObjectName="Product" enableCountByExample="false" enableDeleteByExample="false" enableSelectByExample="false" enableUpdateByExample="false">-->
<!-- <columnOverride column="detail" jdbcType="VARCHAR" />-->
<!-- <columnOverride column="sub_images" jdbcType="VARCHAR" />-->
<!-- </table>-->
<table tableName="mall_user" domainObjectName="User" enableCountByExample="false" enableDeleteByExample="false" enableSelectByExample="false" enableUpdateByExample="false"/>

</context>
</generatorConfiguration>

上面是generatorConfig.xml

在cmd运行mvn mybatis-generator:generate即可自动生成文件

在windows的cmd运行时需要加上 -Dfile.encoding=UTF-8,要不然读取文件会出现invalid utf-8 middle byte 0xed这个问题。这个问题搞了我一下午,以此谨记。

同时IDEA的编码设置一定记得改成UTF-8

1.由于不是同一个账号申请的阿里云服务器,首先内网互通得通过云企业网进行

2.搭建hadoop集群/etc/hosts不要有多余东西,但是得把服务器别名加上去,要不然无法启动namenode和datanode,如果多了东西会导致mapreduce卡在running job,这个问题卡了我一上午,最后发现是/etc/hosts多了东西,/etc/hosts的内容如下就行:

hp101 172.16.43.24 iZ2ze9h4i9zzh81qbjzpv2Z
hp102 172.16.89.37 iZ2ze9lmwvohjf8pqv1rtzZ

leetcode28题解法

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/**
* @author xixing
* @version 1.0
* @date 2020/3/9 15:25
*/
public class N28 {
public static int strStr(String haystack, String needle) {

if(needle.length()==0){
return 0;
}
int[] next=getNext(needle);
int i=0,j=0;
while (i<haystack.length()&&j<needle.length()){
if(j==-1||haystack.charAt(i)==needle.charAt(j)){
i++;
j++;
}else {
j=next[j];
}

}
if(j==needle.length()){
return i-j;
}
else {
return -1;
}


}
public static int[] getNext(String needle){
char[] str=needle.toCharArray();
int[] next=new int[needle.length()];
next[0]=-1;
int j=0,k=-1;
while (j<str.length-1){
if(k==-1||str[j]==str[k]){
next[++j]=++k;
}
else {
k=next[k];
}

}
return next;

}

public static void main(String[] args) {
strStr("mississippi", "issip");
String aaa="aaa";
aaa.indexOf("ll");
}
}

kmp字符串匹配算法是目前很好的的一个字符串匹配算法,通过查看大多数资料,发现next数组只与needle本身有关。

通过leetcode题解,可以把next数组里面的数字当成有限确定自动机,具体可以参考以下网址

kmp算法讲解

leetcode题解

java代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package site.xixing.array;

import java.lang.reflect.Array;
import java.util.Arrays;

/**
* @author xixing
* @version 1.0
* @date 2020/3/3 10:08
*/
public class N1001 {
public static void merge(int[] A, int m, int[] B, int n) {
for(int i=n,j=0;i<A.length;i++){
A[i]=B[j];
j++;
}
int[] temp=new int[A.length];
sort(A,0,A.length-1,temp);
System.out.println(A.toString());


}
public static void merge1(int[] a,int start,int mid,int end,int [] temp){
int i=start;
int j=mid+1;
int t=0;
while (i<=mid&&j<=end){
if(a[i]<a[j]){
temp[t++]=a[i++];
}
else {
temp[t++]=a[j++];
}
}
while (i<=mid){
temp[t++]=a[i++];
}
while (j<=end){
temp[t++]=a[j++];
}
t=0;
while (start<=end){
a[start++]=temp[t++];
}


}
public static void sort(int[] a,int start,int end,int[] temp){
if(start<end){
int mid=(end+start)/2;
sort(a,start,mid,temp);//递归下去
sort(a,mid+1,end,temp);
merge1(a,start,mid,end,temp);


}
}

public static void main(String[] args) {
int[] A={1,2,3,0,0,0};
int[] B={1,4,3};
merge(A,3,B,3);

}

}

图解

image-ugiuguygg

image-20200303112239970

image-20200303112349323

参考链接cnblogs