NutzCN Logo
问答 不兼容的类型: java.lang.String无法转换为org.nutz.lang.util.NutMap
发布于 2336天前 作者 qq_c766893a 3805 次浏览 复制 上一个帖子 下一个帖子
标签:

今天在打包项目时出现这个报错,日常编译并没有问题,不知是为什么。

CloudVisitApply syncData = CloudVisitApply.builder()
                        .visitorName(user.getName())
                        .visitorCompanyName(cloudCompany.getName())
                        .idType(user.getIdType())
                        .idNumber(user.getIdNumber())
                        .visitorMobile(user.getMobile())
                        .visitorImageBase64(imageBase64)
                        .userUid(cloudUser.getUid())
                        .visitorId(cloudVisitApply.getVisitorId())
                        .visitorFaceId(cloudVisitApply.getVisitorFaceId())
                        .carNumber(cloudVisitApply.getCarNumber())
                        .visitType(cloudVisitApply.getVisitType())
                        .visitDescription(cloudVisitApply.getVisitDescription())
                        .status("2")
                        .visitDate(cloudVisitApply.getVisitDate())
                        .visitTimeStart(cloudVisitApply.getVisitTimeStart())
                        .visitTimeEnd(cloudVisitApply.getVisitTimeEnd())
                        .applyTime(cloudVisitApply.getApplyTime())
                        .build();

                //异步推送到消息队列
                RabbitMessage msg = new RabbitMessage(EXCHANGE, ROUTE_KEY + "." + cloudCompany.getClientCompanyUid(), Json.toJson(syncData));//打包项目提示这里报错
                rabbitProducer.sendMessage(msg);
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] /Users/admin/IdeaProjects/git/visitor-cloud/wk-app/wk-web/src/main/java/cn/wizzer/app/visitor/modules/services/impl/CloudVisitApplyServiceImpl.java:[119,130] 不兼容的类型: java.lang.String无法转换为org.nutz.lang.util.NutMap
[ERROR] /Users/admin/IdeaProjects/git/visitor-cloud/wk-app/wk-web/src/main/java/cn/wizzer/app/visitor/modules/services/impl/CloudVisitApplyServiceImpl.java:[162,132] 不兼容的类型: java.lang.String无法转换为org.nutz.lang.util.NutMap
[INFO] 2 errors 
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO] 
[INFO] wk-app ............................................. SUCCESS [  0.010 s]
[INFO] wk-web ............................................. FAILURE [ 16.879 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 17.211 s
[INFO] Finished at: 2018-07-31T11:22:34+08:00
[INFO] Final Memory: 27M/385M
8 回复

119和162分别是哪行

//异步推送到消息队列
                RabbitMessage msg = new RabbitMessage(EXCHANGE, ROUTE_KEY + "." + cloudCompany.getClientCompanyUid(), Json.toJson(syncData));//打包项目提示这里报错

119和169都是这条代码,提示的是Json.toJson(syncData)这里有问题

RabbitMessage是什么东西? 最近修改过?

package cn.wizzer.framework.rabbit;

import org.nutz.lang.Lang;
import org.nutz.lang.util.NutMap;

import java.io.Serializable;

/**
 * 消息实体类
 * Created by wizzer on 2016/12/29.
 */
public class RabbitMessage implements Serializable {
    private static final long serialVersionUID = -6778170718151494509L;

    /**
     * 交换器
     */
    private String exchange;

    private byte[] body;

    /**
     * 路由key
     */
    private String routeKey;

    public RabbitMessage() {
    }

    public RabbitMessage(String exchange, String routeKey, NutMap nutMap) {
        this.exchange = exchange;
        this.routeKey = routeKey;
        this.body = Lang.toBytes(nutMap);
    }

    public RabbitMessage(String exchange, String routeKey, String data) {
        this.exchange = exchange;
        this.routeKey = routeKey;
        this.body = Lang.toBytes(data);
    }

    public String getExchange() {
        return exchange;
    }

    public void setExchange(String exchange) {
        this.exchange = exchange;
    }

    public byte[] getBody() {
        return body;
    }

    public void setBody(byte[] body) {
        this.body = body;
    }

    public String getRouteKey() {
        return routeKey;
    }

    public void setRouteKey(String routeKey) {
        this.routeKey = routeKey;
    }
}

这是现在的RabbitMessage,增加了构造方法

mvn clean package install

Results :

Tests in error: 
  CloudUserServiceImplTest.testSyncUserInfo:104 » Runtime Can not find file '/Us...
  UserTest.test5:147 » ArrayIndexOutOfBounds 1

Tests run: 29, Failures: 0, Errors: 2, Skipped: 0

[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO] 
[INFO] wk-app ............................................. SUCCESS [  0.456 s]
[INFO] wk-web ............................................. FAILURE [ 27.523 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 28.174 s
[INFO] Finished at: 2018-07-31T11:50:37+08:00
[INFO] Final Memory: 31M/408M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.19.1:test (default-test) on project wk-web: There are test failures.
[ERROR] 
[ERROR] Please refer to /Users/admin/IdeaProjects/git/visitor-cloud/wk-app/wk-web/target/surefire-reports for the individual test results.
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
[ERROR] 
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <goals> -rf :wk-web

似乎还是不行

变成testcase不过了, 删掉或者跳过测试

ok了,感谢!

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