Skip to content
This repository has been archived by the owner on Jul 11, 2018. It is now read-only.

TDDL与Spring-Boot报错[Version.java] #11

Open
xinghalo opened this issue Sep 27, 2017 · 0 comments
Open

TDDL与Spring-Boot报错[Version.java] #11

xinghalo opened this issue Sep 27, 2017 · 0 comments

Comments

@xinghalo
Copy link

xinghalo commented Sep 27, 2017

2017-09-27 11:15:58,428 [main] ERROR com.taobao.tddl.common.utils.version.Version:74 -  [TDDL] check guava version is recommend <= 15.0(the minimum version), please upgrade guava jar version, tddl version: recommend
java.lang.IllegalStateException: check guava version is recommend <= 15.0(the minimum version), please upgrade guava jar version
	at com.taobao.tddl.common.utils.version.Version.validVersion(Version.java:122)
	at com.taobao.tddl.common.utils.version.Version.<clinit>(Version.java:36)
	at com.taobao.tddl.monitor.logger.LoggerInit.initTddlLog(LoggerInit.java:42)
	at com.taobao.tddl.monitor.logger.LoggerInit.<clinit>(LoggerInit.java:32)
	at com.taobao.tddl.group.jdbc.TGroupDataSource.doInit(TGroupDataSource.java:117)
	at com.taobao.tddl.common.model.lifecycle.AbstractLifecycle.init(AbstractLifecycle.java:21)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)

如上,其实是Version代码在检测jar版本的时候出错了。
比如在spring-boot中检测的代码位置为:

file:/Users/xingoo/IdeaProjects/test-recommend/target/recommend.jar!/BOOT-INF/lib/guava-20.0.jar!/com/google/common/collect/MapMaker.class
version:recommend

因此需要修改检测jar版本的代码:

public static String getVerionByPath(String file) {
        if (file != null && file.length() > 0 && StringUtils.contains(file, ".jar")) {
            int index = StringUtils.indexOf(file, ".jar");
            file = file.substring(0, index);
            int i = file.lastIndexOf('/');
            if (i >= 0) {
                file = file.substring(i + 1);
            }
            i = file.indexOf("-");
            if (i >= 0) {
                file = file.substring(i + 1);
            }
            while (file.length() > 0 && !Character.isDigit(file.charAt(0))) {
                i = file.indexOf("-");
                if (i >= 0) {
                    file = file.substring(i + 1);
                } else {
                    break;
                }
            }
            return file;
        } else {
            return null;
        }
    }

修改为:

int index = StringUtils.lastIndexOf(file, ".jar");
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant