1.加载配置文件,读取配置文件内容
import java.util.ResourceBundle; //导util包 ResourceBundle auth = ResourceBundle.getBundle("auth"); //获取auth.properties配置文件 ,jar包为jdk自带 String key = auth.getString("key");//获得配置文件的键
获取跟目录文件
// String path = Test.class.getClassLoader().getResource("Movie.json").getPath();
// String path="/E:/zbh/数据采集/大数据/440000/"+"fileName"+".json";
2.手动打jar包到maven本地仓库(因为maven中央库没有该jar才这样做)
先下载好改jar包,如fastdfs_client_v1.20.jar,然后在cmd执行如下命令,注意后面是jar包在本地放的位置
mvn install:install-file -DgroupId=org.csource.fastdfs -DartifactId=fastdfs -Dversion=1.2 -Dpackaging=jar -Dfile=d:setupfastdfs_client_v1.20.jar
然后添加依赖即可
<dependency> <groupId>org.csource.fastdfs</groupId> <artifactId>fastdfs</artifactId> <version>1.2</version> </dependency>
本地运行jar包命令
java -jar zipkin-server-2.10.1-exec.jar
三木运算
//空格处理 String keywords= (String)searchMap.get("keywords"); keywords=keywords==null?"":(String)searchMap.get("keywords");
return user == null ? "没有找到用户信息" : user.toString();
switch (type) { case 0: criteria.andCategoryEqualTo(condition); break; }
字符串值非空判断
!"".equals(searchMap.get("category"))
数组转集合
Arrays.asList(ids)
加logger日志
import org.apache.log4j.Logger; private static Logger logger=Logger.getLogger(ItemPageServiceImpl.class); logger.error(e.getMessage());
或者
import org.slf4j.Logger; import org.slf4j.LoggerFactory;
private static final Logger logger = LoggerFactory.getLogger(IndexController.class);
JSON字符串转java集合
import com.alibaba.fastjson.JSON; List<TbItem> itemList = JSON.parseArray(text, TbItem.class);
忽略大小写
if(audioType.equalsIgnoreCase("vlc") ){
用java自带包生成uuid
UUID.randomUUID().toString();