jeecgboot / JimuReport

「数据可视化:报表、仪表盘、大屏」积木报表是一款类Excel操作风格,在线拖拽设计的报表工具和和数据可视化产品。功能涵盖: 报表设计、打印设计、图形报表、仪表盘门户设计、大屏设计等,完全免费!秉承“简单、易用、专业”的产品理念,极大的降低报表开发难度、缩短开发周期、解决各类报表难题。
http://jimureport.com
GNU General Public License v3.0
6.52k stars 1.66k forks source link

快速集成后无法打开预览界面 #525

Closed pandichao closed 3 years ago

pandichao commented 3 years ago
版本号:

1.3.795

问题描述:

首先是一个springboot空工程快速集成的jimu报表,测试一下,是可以预览等使用的,但是当集成到现有框架模块中的时候,发现无法使用预览功能,控制台无报错日志,前端一直在加载中,且两个工程的配置是copy的,数据库也是同一个数据库

错误日志&截图:

浏览器界面如下: image

后台代码控制台输出如下(info): image

重现步骤:

大概贴一下配置项:

pom配置

<parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.4.5</version>
        <relativePath/>
    </parent>

        <groupId>com.hearyou</groupId>
    <artifactId>ihap-jimu-report</artifactId>
    <version>${ihap.version}</version>
    <name>${artifactId}</name>
    <description>ihap-积木报表</description>
    <packaging>jar</packaging>

       <properties>
            <java.version>1.8</java.version>
            <common.version>1.0</common.version>
            <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
       </properties>

        <repositories>
        <repository>
            <id>aliyun</id>
            <name>aliyun Repository</name>
            <url>http://maven.aliyun.com/nexus/content/groups/public</url>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
        <repository>
            <id>jeecg</id>
            <name>jeecg Repository</name>
            <url>http://maven.jeecg.org/nexus/content/repositories/jeecg</url>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
    </repositories>

      <dependencyManagement>
        <dependencies>
            <!--cloud alibaba 2021 + Cloud 2020.0-->
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>2020.0.3</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>

            <dependency>
                <groupId>com.alibaba.cloud</groupId>
                <artifactId>spring-cloud-alibaba-dependencies</artifactId>
                <version>2021.1</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

      <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-aop</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-validation</artifactId>
        </dependency>

        <!--默认springCloud 2020开始移除了bootstrap.yaml的启动引导项,不添加无法启动-->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-bootstrap</artifactId>
            <version>3.0.3</version>
        </dependency>

        <dependency>
            <groupId>javax.inject</groupId>
            <artifactId>javax.inject</artifactId>
            <version>1</version>
        </dependency>

        <!--jackson依赖包-->
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
        </dependency>

        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-annotations</artifactId>
        </dependency>

        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-core</artifactId>
        </dependency>

                <!--nacos注册中心 依赖-->
        <dependency>
            <groupId>com.alibaba.cloud</groupId>
            <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
        </dependency>

        <dependency>
            <groupId>com.alibaba.cloud</groupId>
            <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
        </dependency>

        <!--RPC注册 nacos-->
        <dependency>
            <groupId>com.alibaba.cloud</groupId>
            <artifactId>spring-cloud-starter-dubbo</artifactId>
        </dependency>

        <dependency>
            <groupId>org.jeecgframework.jimureport</groupId>
            <artifactId>jimureport-spring-boot-starter</artifactId>
            <!--<version>1.3.78</version>-->
            <version>1.3.795</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-freemarker</artifactId>
        </dependency>

                <!--数据库依赖-->
        <dependency>
            <groupId>com.oracle</groupId>
            <artifactId>ojdbc6</artifactId>
            <version>11.2.0.3</version>
        </dependency>

        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <scope>runtime</scope>
        </dependency>
    </dependencies>

    <build>
           <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                                <version>3.8.1</version>
                <configuration>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                    <encoding>${project.build.sourceEncoding}</encoding>
                                </configuration>
            </plugin>
        </plugins>

               <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
            </resource>

            <resource>
                <directory>src/main/resources</directory>
            </resource>

            <resource>
                <directory>src/main/java</directory>
                <filtering>false</filtering>
                <includes>
                    <include>**/mapper/*.xml</include>
                </includes>
            </resource>
        </resources>
      </build>

bootstrap.yml 配置如下

dubbo:
  application:
    name: ${spring.application.name}
    id: ${spring.application.name}
  scan:
    base-packages: com.hearyou.ihap.customer.service.impl
  protocol:
    name: dubbo
    port: -1
  registry:
    #作为服务发布注册的地址,指定使用springCloud的配置作为注册地址
    address: spring-cloud://localhost
  cloud:
    #作为消费者能调用到哪些服务的订阅(服务提供方的应用名称的列表,若需订阅多应用,使用 "," 分割)
    subscribed-services:
  consumer:
    timeout: 30000
    retries: -1

#Minidao配置
minidao:
  base-package: org.jeecg.modules.jmreport.*

#JimuReport[上传配置]
jeecg :
  # local|minio|alioss
  uploadType: local
  # local
  path :
    #文件路径
    upload: D:\opt\upload
  # alioss
  oss:
    endpoint: ??
    accessKey: ??
    secretKey: ??
    bucketName: jimureport
  # minio
  minio:
    minio_url: http://minio.jeecg.com
    minio_name: ??
    minio_pass: ??
    bucketName: ??

spring:
  application:
    name: @project.name@
    profiles:
      active: dev
    main:
      allow-bean-definition-overriding: true
  cloud:
    nacos:
      discovery:
        server-addr: 192.168.1.123:18848
        namespace: hap-dev
        username: nacos-b2b
        password: nacos-b2b
        group: IHAP
      config:
        server-addr: 192.168.1.123:18848
        namespace: hap-dev
        group: IHAP
        prefix: ihap-jimu-report
        file-extension: yaml
        refresh: true

#输出sql日志
logging:
  level:
    org.jeecg.modules.jmreport : info

nacos上的配置文件 ihap-jimu-report.yaml内容大概如下:

server:
  port: 10800

spring:
  #配置静态资源
  mvc:
    static-path-pattern: /**
  resource:
    static-locations: classpath:/static/
  #配置数据库
  datasource:
    url: jdbc:mysql://${mysql-url:192.168.1.123.10}:${mysql-port:13306}/${mysql-db:jimu_report}?serverTimezone=UTC&useUnicode=true&characterEncoding=utf-8&allowPublicKeyRetrieval=true
    username: ${mysql.username:dev_admin}
    password: ${mysql.password:123456}
    driver-class-name: com.mysql.cj.jdbc.Driver

启动类 ReportApplication内容如下:

@EnableDiscoveryClient
@SpringBootApplication(scanBasePackages = {"com.hearyou.report","org.jeecg.modules.jmreport"})
@Slf4j
public class ReportApplication {

    public static void main(String[] args) {
        ConfigurableApplicationContext applicationContext = SpringApplication.run(ReportApplication.class);
        Environment env = applicationContext.getEnvironment();
        String port = env.getProperty("server.port");
        String path = env.getProperty("server.servlet.context-path");
        if(StrUtil.isBlank(path)){
            path = "";
        }else{
            if(!path.startsWith("/")){
                path = "/".concat(path);
            }
        }

        log.info("ReportApplication is running!URL:\t\t http://localhost:{}{}/jmreport/list",port,path);
    }
}

补充说明

前端日志对比,我的工程集成完毕后,浏览器控制台报错,如下: image

官方demo的控制台日志输出如下: image

test:开头的部分开始都是没有的,因为代码不开源的原因,无法排查前端,仅作为参考辅助,除此之外,两个工程的后台日志完全一样,并且浏览器network显示的响应也都是一样,每个接口都成功返回响应,日志如下: image

image 可以看到,这个接口响应的应该就是前端渲染的报表数据,已经正常返回了,只是result下面的dataList字段获取不到,导致undefind

pandichao commented 3 years ago

这是简化的版本配置,希望能得到反馈

zhangdaiscott commented 3 years ago

你是springboot项目吗

pandichao commented 3 years ago

你是springboot项目吗

是的,springboot项目,同时也集成了springcloud和springcloud alibaba最新版本

zhangdaiscott commented 3 years ago

扫码路径,自己排查

pandichao commented 3 years ago

扫码路径,自己排查

什么意思,你意思是扫描路径的问题?

pandichao commented 3 years ago

扫码路径,自己排查

扫描路径是copy的官方demo里面的呀?还是哪里不对

pandichao commented 3 years ago

已经排查到问题,如上面所说,是/jmreport/show接口数据响应导致的问题,我怀疑积木报表应该是用的当前工程中的json转换配置(jackson配置),因为我们是遵循驼峰规范的,默认配置中jackson是将所有字段都默认转换为下划线,而很明显官方的demo中响应的数据都是驼峰的,首字母大写格式,因此导致前端控制台报错,建议积木报表团队考虑使用固定的json输出,而不是使用工程默认的配置,否则可能会导致集成到已有项目模块中出现json输出格式不一致的问题

扫码路径,自己排查

lvdandan16 commented 3 years ago

收录 ws

1298191366 commented 3 years ago

后台返回的是jsonStr,因为前台接收的就是jsonStr,如果配置jackson,前台接受多的参数默认变成了json_str。目前需要走默认的jackson驼峰格式

tygithub1 commented 3 years ago

张三请李四去自家吃饭,张三一家都是身形彪悍,人高马大,吃饭都是一人一个锅啃,李四骨瘦如柴,弱不禁风,张三表示,俺们都是吃大锅饭,来,给你一个锅,吃完他,不要浪费粮食,但是李四肯定是吃不完一锅饭的,张三表示,你以后来我家吃饭记得带个小碗,哦,这就有意思了,然后这个村里,但凡去张三家吃饭的,都要自带个合适的碗,甚至于,饭菜不合口的,都自备材米油盐,他么的那还要去张三家干啥?