-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
yagol2020
committed
Nov 17, 2021
1 parent
59c9d36
commit 5594f54
Showing
18 changed files
with
493 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package config; | ||
|
||
import cn.hutool.core.io.FileUtil; | ||
import cn.hutool.core.util.CharsetUtil; | ||
import cn.hutool.setting.yaml.YamlUtil; | ||
import config.property.ChromeProperties; | ||
import lombok.Data; | ||
import param.NormalParam; | ||
|
||
/** | ||
* @author yagol | ||
* @TIME 2021/11/17 - 7:16 下午 | ||
* @Description 配置类获取类 | ||
**/ | ||
@Data | ||
public class MyConfig { | ||
ChromeProperties chrome; | ||
|
||
/** | ||
* 初始化config,并获得jar外部的config | ||
* | ||
* @param configSavePath | ||
* @return | ||
*/ | ||
public static MyConfig initConfig(String configSavePath) { | ||
MyConfig config = YamlUtil.loadByPath("config/" + NormalParam.CONFIG_FILE_NAME, MyConfig.class); | ||
return createOrUpdateConfig(config, configSavePath); | ||
} | ||
|
||
/** | ||
* 在不修改的情况下,获得config | ||
* | ||
* @param configPath | ||
* @return | ||
*/ | ||
public static MyConfig getConfig(String configPath) { | ||
return YamlUtil.loadByPath(configPath + NormalParam.CONFIG_FILE_NAME, MyConfig.class); | ||
} | ||
|
||
/** | ||
* 将传进来的config保存到制定文件中 | ||
* | ||
* @param config | ||
* @param configPath | ||
* @return | ||
*/ | ||
public static MyConfig createOrUpdateConfig(MyConfig config, String configPath) { | ||
YamlUtil.dump(config, | ||
FileUtil.getWriter | ||
(configPath + NormalParam.CONFIG_FILE_NAME, | ||
CharsetUtil.CHARSET_UTF_8, | ||
false | ||
) | ||
); | ||
return getConfig(configPath); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package config.property; | ||
|
||
import lombok.Data; | ||
|
||
/** | ||
* @author yagol | ||
* @TIME 2021/11/17 - 7:21 下午 | ||
* @Description | ||
**/ | ||
@Data | ||
public class ChromeProperties { | ||
String driverPath; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.