ebom转PBOM报错问题-版本号问题
This commit is contained in:
parent
802203f4d4
commit
969af82393
|
|
@ -5,7 +5,9 @@ import cn.hutool.core.convert.Convert;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import org.springframework.data.util.Version;
|
import org.springframework.data.util.Version;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import static org.apache.naming.SelectorContext.prefix;
|
import static org.apache.naming.SelectorContext.prefix;
|
||||||
|
|
||||||
|
|
@ -59,6 +61,7 @@ public class VersionUtil {
|
||||||
// Split the previous version number into its components
|
// Split the previous version number into its components
|
||||||
String[] previousComponents = previousVersion.replace(versionPrefix, "").split("\\.");
|
String[] previousComponents = previousVersion.replace(versionPrefix, "").split("\\.");
|
||||||
|
|
||||||
|
previousComponents= filterNumericStrings(previousComponents).toArray(new String[0]);
|
||||||
int previousMajor = Integer.parseInt(previousComponents[0]);
|
int previousMajor = Integer.parseInt(previousComponents[0]);
|
||||||
int previousMinor = previousComponents.length < 2 ? 0 : Integer.parseInt(previousComponents[1]);
|
int previousMinor = previousComponents.length < 2 ? 0 : Integer.parseInt(previousComponents[1]);
|
||||||
|
|
||||||
|
|
@ -86,6 +89,43 @@ public class VersionUtil {
|
||||||
return nextVersion;
|
return nextVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 过滤出数组中仅包含数字的字符串。
|
||||||
|
*
|
||||||
|
* @param array 输入的字符串数组
|
||||||
|
* @return 包含数字字符串的列表
|
||||||
|
*/
|
||||||
|
public static List<String> filterNumericStrings(String[] array) {
|
||||||
|
List<String> result = new ArrayList<>();
|
||||||
|
for (String s : array) {
|
||||||
|
if (isNumeric(s)) {
|
||||||
|
result.add(s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检查给定的字符串是否表示一个数字。
|
||||||
|
* 支持整数、浮点数和科学计数法表示的数字。
|
||||||
|
*
|
||||||
|
* @param str 要检查的字符串
|
||||||
|
* @return 如果字符串表示一个数字,则返回true;否则返回false
|
||||||
|
*/
|
||||||
|
private static boolean isNumeric(String str) {
|
||||||
|
if (str == null || str.isEmpty()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
// 尝试将字符串转换为Double类型
|
||||||
|
Double.parseDouble(str);
|
||||||
|
return true;
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
// 如果转换失败,说明不是有效的数字格式
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 版本比较
|
* 版本比较
|
||||||
* @param version1
|
* @param version1
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue