NutzCN Logo
问答 大叔 我在DBsetup这个类里使用了http.get(url)方法
发布于 2535天前 作者 lalala 1541 次浏览 复制 上一个帖子 下一个帖子
标签:

结果就报错误了,项目还没启动完毕不能使用这个方法吗

11 回复

门店的经纬度 我不想放到数据库中 我想放在redis的geo中,项目加载的时候 用了http.get方法带门店地址去请求高德地址api获取经纬度 并存在redis geo中, 有别的解决方法吗!!

没有什么信息啊

2017-12-07 19:46:32 [org.nutz.ioc.impl.NutIoc]-[DEBUG] Get 'conf'<>
2017-12-07 19:46:32 [org.nutz.ioc.impl.NutIoc]-[DEBUG] Get 'jedisPoolConfig'<>
2017-12-07 19:46:32 [org.nutz.ioc.impl.NutIoc]-[DEBUG] Get 'conf'<>
2017-12-07 19:46:32 [org.nutz.ioc.impl.NutIoc]-[DEBUG] Get 'conf'<>
2017-12-07 19:46:32 [org.nutz.ioc.impl.NutIoc]-[DEBUG] Get 'conf'<>
2017-12-07 19:46:32 [org.nutz.ioc.impl.NutIoc]-[DEBUG] Get 'conf'<>
2017-12-07 19:46:32 [org.nutz.ioc.impl.NutIoc]-[DEBUG] Get 'conf'<>
[INFO] Started ServerConnector@5e24592e{HTTP/1.1,[http/1.1]}{0.0.0.0:8082}
[INFO] Jetty server exiting.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 11.220 s
[INFO] Finished at: 2017-12-07T19:46:32+08:00
[INFO] Final Memory: 23M/264M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.eclipse.jetty:jetty-maven-plugin:9.4.6.v20170531:run (default-cli) on project xhd-shop-app: Execution default-cli of goal org.eclipse.jetty:jetty-maven-plugin:9.4.6.v20170531:run failed: A required class was missing while executing org.eclipse.jetty:jetty-maven-plugin:9.4.6.v20170531:run: org/json/JSONObject
[ERROR] -----------------------------------------------------
[ERROR] realm =    plugin>org.eclipse.jetty:jetty-maven-plugin:9.4.6.v20170531
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/C:/Users/guojx/.m2/repository/org/eclipse/jetty/jetty-maven-plugin/9.4.6.v20170531/jetty-maven-plugin-9.4.6.v20170531.jar
[ERROR] urls[1] = file:/C:/Users/guojx/.m2/repository/org/sonatype/sisu/sisu-inject-bean/2.1.1/sisu-inject-bean-2.1.1.jar
[ERROR] urls[2] = file:/C:/Users/guojx/.m2/repository/org/sonatype/sisu/sisu-guice/2.9.4/sisu-guice-2.9.4-no_aop.jar
[ERROR] urls[3] = file:/C:/Users/guojx/.m2/repository/org/codehaus/plexus/plexus-utils/2.0.6/plexus-utils-2.0.6.jar
[ERROR] urls[4] = file:/C:/Users/guojx/.m2/repository/org/sonatype/aether/aether-util/1.11/aether-util-1.11.jar
[ERROR] urls[5] = file:/C:/Users/guojx/.m2/repository/org/codehaus/plexus/plexus-interpolation/1.14/plexus-interpolation-1.14.jar
[ERROR] urls[6] = file:/C:/Users/guojx/.m2/repository/org/codehaus/plexus/plexus-component-annotations/1.5.5/plexus-component-annotations-1.5.5.jar
[ERROR] urls[7] = file:/C:/Users/guojx/.m2/repository/org/sonatype/plexus/plexus-sec-dispatcher/1.3/plexus-sec-dispatcher-1.3.jar
[ERROR] urls[8] = file:/C:/Users/guojx/.m2/repository/org/sonatype/plexus/plexus-cipher/1.4/plexus-cipher-1.4.jar
[ERROR] urls[9] = file:/C:/Users/guojx/.m2/repository/org/apache/maven/plugin-tools/maven-plugin-tools-api/3.4/maven-plugin-tools-api-3.4.jar
[ERROR] urls[10] = file:/C:/Users/guojx/.m2/repository/backport-util-concurrent/backport-util-concurrent/3.1/backport-util-concurrent-3.1.jar
[ERROR] urls[11] = file:/C:/Users/guojx/.m2/repository/org/eclipse/jetty/jetty-util/9.4.6.v20170531/jetty-util-9.4.6.v20170531.jar
...
public class APPSetup implements Setup {
    private static final Log log = Logs.get();
    @Override
    public void init(NutConfig nc) {
        /**检查当前项目环境是否为utf-8*/
        if (!Charset.defaultCharset().name().equalsIgnoreCase(Encoding.UTF8)) {
            log.error("This project must running in utf-8,please modify encoding = utf-8");
        }
        Ioc ioc = nc.getIoc();
        Dao dao = ioc.get(Dao.class);
        Daos.createTablesInPackage(dao,"com.xhd.shop",false);
        Daos.migration(dao,"com.xhd.shop",true,true);
        // 参数初始化
        InitData init = new InitData(ioc);
        init.initStoreAddress();
    }

    @Override
    public void destroy(NutConfig nutConfig) {

    }


}

参数初始化那两行代码,用 try catch 包裹起来,打印异常信息

大叔 我自己解决了啦

怎么解决的?说下呗

都不是框架的问题啦 RedisService geoadd方法 类型强制转换抛出的问题而已

在 for里面 使用了

 geoposList = redisService.geopos(RedisKey.store_address_key, storeInfo.getId() + "");

redis 上面都是空的,没有数据 第一次返回的是null size 等于0,
第二次 内容还是空 debug了一下 size却等于1,geoposList则显示all Element are null

.. geohash 如果key不存在,number不存在 返回的是[] 如果key存在,number不存在 返回的值是[null]!!

添加回复
请先登陆
回到顶部