flink 项目打包成jar运行异常

flink项目打包成jar运行后,报如下错误。

Exception in thread "main" com.typesafe.config.ConfigException$UnresolvedSubstitution: reference.conf @ jar:file:/D:/ProjectCode/flinkdemo/target/flinkdemo-1.0-SNAPSHOT-jar-with-dependencies.jar!/reference.conf: 875: Could not resolve substitution to a value: ${akka.stream.materializer}
        at com.typesafe.config.impl.ConfigReference.resolveSubstitutions(ConfigReference.java:111)
        at com.typesafe.config.impl.ResolveContext.realResolve(ResolveContext.java:179)
        at com.typesafe.config.impl.ResolveContext.resolve(ResolveContext.java:142)
        at com.typesafe.config.impl.SimpleConfigObject$ResolveModifier.modifyChildMayThrow(SimpleConfigObject.java:379)
        at com.typesafe.config.impl.SimpleConfigObject.modifyMayThrow(SimpleConfigObject.java:312)
        at com.typesafe.config.impl.SimpleConfigObject.resolveSubstitutions(SimpleConfigObject.java:398)
        at com.typesafe.config.impl.ResolveContext.realResolve(ResolveContext.java:179)
        at com.typesafe.config.impl.ResolveContext.resolve(ResolveContext.java:142)
        at com.typesafe.config.impl.SimpleConfigObject$ResolveModifier.modifyChildMayThrow(SimpleConfigObject.java:379)
        at com.typesafe.config.impl.SimpleConfigObject.modifyMayThrow(SimpleConfigObject.java:312)
        at com.typesafe.config.impl.SimpleConfigObject.resolveSubstitutions(SimpleConfigObject.java:398)
        at com.typesafe.config.impl.ResolveContext.realResolve(ResolveContext.java:179)
        at com.typesafe.config.impl.ResolveContext.resolve(ResolveContext.java:142)
        at com.typesafe.config.impl.SimpleConfigObject$ResolveModifier.modifyChildMayThrow(SimpleConfigObject.java:379)
        at com.typesafe.config.impl.SimpleConfigObject.modifyMayThrow(SimpleConfigObject.java:312)
        at com.typesafe.config.impl.SimpleConfigObject.resolveSubstitutions(SimpleConfigObject.java:398)
        at com.typesafe.config.impl.ResolveContext.realResolve(ResolveContext.java:179)
        at com.typesafe.config.impl.ResolveContext.resolve(ResolveContext.java:142)
        at com.typesafe.config.impl.SimpleConfigObject$ResolveModifier.modifyChildMayThrow(SimpleConfigObject.java:379)
        at com.typesafe.config.impl.SimpleConfigObject.modifyMayThrow(SimpleConfigObject.java:312)
        at com.typesafe.config.impl.SimpleConfigObject.resolveSubstitutions(SimpleConfigObject.java:398)
        at com.typesafe.config.impl.ResolveContext.realResolve(ResolveContext.java:179)
        at com.typesafe.config.impl.ResolveContext.resolve(ResolveContext.java:142)
        at com.typesafe.config.impl.SimpleConfigObject$ResolveModifier.modifyChildMayThrow(SimpleConfigObject.java:379)
        at com.typesafe.config.impl.SimpleConfigObject.modifyMayThrow(SimpleConfigObject.java:312)
        at com.typesafe.config.impl.SimpleConfigObject.resolveSubstitutions(SimpleConfigObject.java:398)
        at com.typesafe.config.impl.ResolveContext.realResolve(ResolveContext.java:179)
        at com.typesafe.config.impl.ResolveContext.resolve(ResolveContext.java:142)
        at com.typesafe.config.impl.ResolveContext.resolve(ResolveContext.java:231)
        at com.typesafe.config.impl.SimpleConfig.resolveWith(SimpleConfig.java:78)
        at com.typesafe.config.impl.SimpleConfig.resolve(SimpleConfig.java:68)
        at com.typesafe.config.impl.SimpleConfig.resolve(SimpleConfig.java:63)
        at com.typesafe.config.impl.SimpleConfig.resolve(SimpleConfig.java:41)
        at com.typesafe.config.impl.ConfigImpl$1.call(ConfigImpl.java:371)
        at com.typesafe.config.impl.ConfigImpl$1.call(ConfigImpl.java:364)
        at com.typesafe.config.impl.ConfigImpl$LoaderCache.getOrElseUpdate(ConfigImpl.java:65)
        at com.typesafe.config.impl.ConfigImpl.computeCachedConfig(ConfigImpl.java:92)
        at com.typesafe.config.impl.ConfigImpl.defaultReference(ConfigImpl.java:364)
        at com.typesafe.config.ConfigFactory.defaultReference(ConfigFactory.java:367)
        at akka.actor.ActorSystem$Settings.<init>(ActorSystem.scala:308)
        at akka.actor.ActorSystemImpl.<init>(ActorSystem.scala:686)
        at akka.actor.RobustActorSystem.<init>(RobustActorSystem.scala:47)
        at akka.actor.RobustActorSystem$.internalApply(RobustActorSystem.scala:96)
        at akka.actor.RobustActorSystem$.apply(RobustActorSystem.scala:70)
        at akka.actor.RobustActorSystem$.create(RobustActorSystem.scala:55)
        at org.apache.flink.runtime.akka.AkkaUtils$.createActorSystem(AkkaUtils.scala:125)
        at org.apache.flink.runtime.akka.AkkaUtils$.createActorSystem(AkkaUtils.scala:113)
        at org.apache.flink.runtime.akka.AkkaUtils.createActorSystem(AkkaUtils.scala)
        at org.apache.flink.runtime.minicluster.MiniCluster.createRpcService(MiniCluster.java:743)
        at org.apache.flink.runtime.minicluster.MiniCluster.start(MiniCluster.java:270)
        at org.apache.flink.client.deployment.executors.LocalExecutor.startMiniCluster(LocalExecutor.java:117)
        at org.apache.flink.client.deployment.executors.LocalExecutor.execute(LocalExecutor.java:63)
        at org.apache.flink.streaming.api.environment.StreamExecutionEnvironment.executeAsync(StreamExecutionEnvironment.java:1733)
        at org.apache.flink.streaming.api.environment.StreamExecutionEnvironment.execute(StreamExecutionEnvironment.java:1634)
        at org.apache.flink.streaming.api.environment.LocalStreamEnvironment.execute(LocalStreamEnvironment.java:74)
        at org.apache.flink.streaming.api.environment.StreamExecutionEnvironment.execute(StreamExecutionEnvironment.java:1620)
        at org.apache.flink.streaming.api.environment.StreamExecutionEnvironment.execute(StreamExecutionEnvironment.java:1602)
        at Application.main(Application.java:37)

网上试了好几种方式都不行,最后在stackoverflow上找到如下方法,可以正常运行。

在pom中添加如下内容。

<build>
    <plugins>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.6.0</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-shade-plugin</artifactId>
            <version>3.1.0</version>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>shade</goal>
                    </goals>
                    <configuration>
                        <transformers>
                            <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                <mainClass>com.spei.Application</mainClass>
                            </transformer>
                            <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                                <resource>reference.conf</resource>
                            </transformer>
                        </transformers>
                        <relocations>
                            <relocation>
                                <pattern>org.codehaus.plexus.util</pattern>
                                <shadedPattern>org.shaded.plexus.util</shadedPattern>
                                <excludes>
                                    <exclude>org.codehaus.plexus.util.xml.Xpp3Dom</exclude>
                                    <exclude>org.codehaus.plexus.util.xml.pull.*</exclude>
                                </excludes>
                            </relocation>
                        </relocations>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

注意以上配置文件在实际使用中,需要修改以下的入口启动类为你项目的入口启动类。    

<mainClass>com.spei.Application</mainClass>

修改成你的!
 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值