1、pom多模块打包
mvn -e clean install -Dmaven.test.skip=true -pl :${module} -am
其中${module}替换为子模块的模块名。
2、读取txt文件
//按行读取存list
public static List<String> read(){
ArrayList<String> arrayList = new ArrayList<>();
try {
File file = new File("D:\\item.txt"); //绝对路径
BufferedReader bf = new BufferedReader(new InputStreamReader(new FileInputStream(file)));
String str;
while ((str = bf.readLine()) != null) {
arrayList.add(str);
}
bf.close();
input.close();
} catch (IOException e) {
e.printStackTrace();
}
return arrayList;
}
//读取所有存入string
public static String read(){
StringBuffer buffer = new StringBuffer();
BufferedReader bf= new BufferedReader(new FileReader(System.getProperty("user.dir")+"/doc/demo.txt")); //相对路径,当前项目根目录下的doc文件下demo.txt
String s;
while((s = bf.readLine())!=null){//使用readLine方法,一次读一行
buffer.append(s.trim());
}
String demo = buffer.toString();
}
3、curl常见使用
post请求,参数是data,值为hello:
curl -X POST -d "data=hello" http://localhost:13201/test
post请求,参数是对象:
curl -X POST -H"Content-Type:application/json" http://localhost:13201/test -d '{ "name":"test", "type":"0", "num":3 }'
4、前端传递参数与后端@responseBody映射参数名大小写保持一致
有时候前端传递全大写字段名,但是后端springboot默认首字母小写,导致参数传递丢失,可以添加如下注解解决。
@JSONField(name="TEXT")
private String TEXT;