Scala与Java混编译:java日志不打印的问题

1.背景

在这里插入图片描述
我本地测试,大部分代码是scla开发,少部分是java代码,然后本地测试都是正确的。

19/09/04 20:01:32 INFO TopoSparkSubmitter: 加载Spark默认配置文件:Some(/etc/spark2/conf/spark-defaults.conf)
19/09/04 20:01:35 INFO SparkConfigUtils: 初始化数组:configShouleNotAdd : [SPARK_MASTER_WEBUI_PORT, HADOOP_CONF_DIR, JAVA_HOME, SCALA_HOME, SPARK_MASTER_PORT, SPARK_MASTER_HOST, SPARK_WORKER_INSTANCES, SPARK_WORKER_PORT, SPARK_WORKER_MEMORY, SPARK_WORKER_CORES, SPARK_WORKER_WEBUI_PORT]
19/09/04 20:01:40 INFO SparkConfigUtils: 加载CDH环境变量 path:/etc/spark2/conf/spark-defaults.conf
19/09/04 20:01:41 INFO SparkConfigUtils: 从path:/etc/spark2/conf/spark-defaults.conf 加载运行的环境参数
19/09/04 20:02:01 INFO SparkConfigUtils: SPARK_HOME:/Users/lcc/soft/spark/spark-2.3.0-bin-hadoop2.7
19/09/04 20:02:01 INFO SparkConfigUtils: 从path:/Users/lcc/soft/spark/spark-2.3.0-bin-hadoop2.7/conf/spark-defaults.conf.template 加载运行的环境参数
19/09/04 20:02:02 INFO SparkConfigUtils: 从path:/Users/lcc/soft/spark/spark-2.3.0-bin-hadoop2.7/conf/spark-defaults.conf 加载运行的环境参数
19/09/04 20:02:03 WARN SparkConfigUtils: 警告 path:/Users/lcc/soft/spark/spark-2.3.0-bin-hadoop2.7/conf/spark-defaults.conf 文件不存在或者是不是文件
19/09/04 20:02:03 INFO SparkConfigUtils: 从path:/Users/lcc/soft/spark/spark-2.3.0-bin-hadoop2.7/conf/spark-env.sh 加载运行的环境参数

这一段是java打下的日志。但是打包到服务器,日志是这样的

19/09/04 19:52:52 INFO TopoSparkSubmitter: 加载Spark默认配置文件:Some(/etc/spark2/conf/spark-defaults.conf)
19/09/04 19:52:52 INFO internal.SharedState: loading hive config file: file:/etc/spark2/conf.cloudera.spark2_on_yarn2/hive-site.xml
19/09/04 19:52:52 INFO internal.SharedState: spark.sql.warehouse.dir is not set, but hive.metastore.warehouse.dir is set. Setting spark.sql.warehouse.dir to the value of hive.metastore.warehouse.dir ('/user/hive/warehouse').
19/09/04 19:52:52 INFO internal.SharedState: Warehouse path is '/user/hive/warehouse'.

java部分的日志没打印。

2.环境

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <parent>
        <artifactId>cheetah-streaming</artifactId>
        <groupId>com.dtwave.cheetah</groupId>
        <version>1.1.0-SNAPSHOT</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>spark-structured-streaming</artifactId>
    <packaging>jar</packaging>



    <dependencies>

        <!-- 引入协议包 -->
        <dependency>
            <groupId>com.dtwave.dipper</groupId>
            <artifactId>node-protocol</artifactId>
        </dependency>


        <dependency>
            <groupId>org.scala-lang</groupId>
            <artifactId>scala-library</artifactId>
            <version>${scala.version}</version>
        </dependency>

        <dependency>
            <groupId>org.scala-lang</groupId>
            <artifactId>scala-compiler</artifactId>
            <version>${scala.version}</version>
        </dependency>

        <dependency>
            <groupId>org.apache.avro</groupId>
            <artifactId>avro</artifactId>
            <version>${avro.version}</version>
        </dependency>


        <!--kudu.version-->
        <dependency>
            <groupId>org.apache.kudu</groupId>
            <artifactId>kudu-client</artifactId>
            <version>${kudu.version}</version>
        </dependency>

        <dependency>
            <groupId>com.oracle.jdbc</groupId>
            <artifactId>ojdbc8</artifactId>
        </dependency>

        <!-- 数据库 mysql -->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
        </dependency>

        <!--spark -->
        <dependency>
            <groupId>org.apache.spark</groupId>
            <artifactId>spark-sql_${scala.compat.version}</artifactId>
            <exclusions>
                <exclusion>
                    <artifactId>avro-mapred</artifactId>
                    <groupId>org.apache.avro</groupId>
                </exclusion>
            </exclusions>
        </dependency>

        <!-- spark sql kafka-->
        <dependency>
            <groupId>org.apache.spark</groupId>
            <artifactId>spark-sql-kafka-0-10_${scala.compat.version}</artifactId>
        </dependency>

        <dependency>
            <groupId>org.apache.spark</groupId>
            <artifactId>spark-hive_${scala.compat.version}</artifactId>
            <exclusions>
                <exclusion>
                    <artifactId>avro-mapred</artifactId>
                    <groupId>org.apache.avro</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>hive-metastore</artifactId>
                    <groupId>org.apache.hive</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>parquet-hadoop</artifactId>
                    <groupId>com.twitter</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>hive-serde</artifactId>
                    <groupId>org.apache.hive</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>hive-shims</artifactId>
                    <groupId>org.apache.hive</groupId>
                </exclusion>
            </exclusions>
        </dependency>

        <!--kudu spark-->
        <dependency>
            <groupId>org.apache.kudu</groupId>
            <artifactId>kudu-spark2_${scala.compat.version}</artifactId>
        </dependency>


        <dependency>
            <groupId>com.dtwave.boot</groupId>
            <artifactId>wolf</artifactId>
            <exclusions>
                <exclusion>
                    <artifactId>spring-core</artifactId>
                    <groupId>org.springframework</groupId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>${slf4j-api.version}</version>
        </dependency>


        <!-- Test -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>${junit.version}</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <!-- see http://davidb.github.com/scala-maven-plugin -->
                <groupId>net.alchim31.maven</groupId>
                <artifactId>scala-maven-plugin</artifactId>
                <version>${net.alchim31.version}</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>compile</goal>
                            <goal>testCompile</goal>
                        </goals>
                        <configuration>
                            <args>
                                <arg>-dependencyfile</arg>
                                <arg>${project.build.directory}/.scala_dependencies</arg>
                            </args>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>${maven.surefire.version}</version>
                <configuration>
                    <!-- Tests will be run with scalatest-maven-plugin instead -->
                    <skipTests>true</skipTests>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${maven.compiler.version}</version>
                <configuration>
                    <encoding>utf-8</encoding>
                    <source>${maven.compiler.source}</source>
                    <target>${maven.compiler.target}</target>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>${maven.shade.version}</version>
                <configuration>
                    <createDependencyReducedPom>false</createDependencyReducedPom>
                </configuration>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <finalName>spark-structured-streaming</finalName>
                            <createDependencyReducedPom>false</createDependencyReducedPom>
                            <filters>
                                <filter>
                                    <artifact>*:*</artifact>
                                    <excludes>
                                        <exclude>META-INF/*.SF</exclude>
                                        <exclude>META-INF/*.DSA</exclude>
                                        <exclude>META-INF/*.RSA</exclude>
                                    </excludes>
                                </filter>
                            </filters>

                            <transformers>
                                <transformer implementation = "org.apache.maven.plugins.shade.resource.AppendingTransformer" >
                                    <resource>META-INF/services/org.apache.spark.sql.sources.DataSourceRegister</resource>
                                </transformer>
                                <transformer implementation ="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                    <mainClass>com.dtwave.cheetah.node.spark.structured.streaming.StructureStreamingExecutor</mainClass>
                                </transformer>
                            </transformers>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

我打开编译后的代码,发现java代码中是有相关的日志的,但是却不打印。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

九师兄

你的鼓励是我做大写作的动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值