无法将替换解析为aws lambda中的值:${akka.stream.materializer}

6yjfywim  于 2021-06-24  发布在  Flink
关注(0)|答案(5)|浏览(414)

我有一个java应用程序,其中使用 Flink Api . 所以基本上我要用代码做的是创建两个数据集,其中只有很少的记录,然后将它们注册为两个表以及必要的字段。

DataSet<Company> comp = env.fromElements(
                new Company("Aux", 1),
                new Company("Comp2", 2),
                new Company("Comp3", 3));

        DataSet<Employee> emp = env.fromElements(
                new Employee("Kula", 1),
                new Employee("Ish", 1),
                new Employee("Kula", 3));

        tEnv.registerDataSet("Employee", emp, "name, empId");
        tEnv.registerDataSet("Company", comp, "cName, empId");

然后我试着用 Table API :

Table anotherJoin = tEnv.sql("SELECT Employee.name, Employee.empId, Company.cName FROM " +
                "Employee RIGHT JOIN Company on Employee.empId = Company.empId");

我只是在控制台上打印结果。这在我的机器上非常有效。我创造了一个 fat-jar 通过使用 maven-shade-plugin 我正试图在aws中执行它 Lambda .
因此,当我尝试在那里执行它时,抛出了以下异常(我只发布了前几行):
reference.conf@file:/var/task/reference.conf:804:无法将替换解析为值:${akka.stream.materializer}:com.typesafe.config.configexception$unsolvedsubstitution com.typesafe.config.configexception$unsolvedsubstitution:reference.conf@file:/var/task/reference.conf:804:无法将替换解析为值:${akka.stream.materializer}位于com.typesafe.config.impl.configreference.resolvesubstitutions(configreference)。java:111)在com.typesafe.config.impl.resolvecontext.realresolve(resolvecontext。java:179)在com.typesafe.config.impl.resolvecontext.resolve(resolvecontext。java:142)
在lambda中执行之前,我提取了jar,碰巧看到所有依赖项都在那里。我不知道哪里出了问题?
任何帮助都将不胜感激。

ugmeyewa

ugmeyewa1#

对于sbt用户来说,这对我很有用。

assemblyMergeStrategy in assembly := {
  {
    case PathList("META-INF", xs@_*) => MergeStrategy.discard
    case "reference.conf" => MergeStrategy.concat
    case x => MergeStrategy.first
  }
}
kd3sttzy

kd3sttzy2#

最终,我发现了这个问题,这是我pom中的一些主要版本问题。然后我将所有依赖项降级为 Flink 1.3.2 还补充了 <relocations>shade 插件。现在可以了。我把整个pom都贴上了,这样总有一天它会帮助别人:

<build>
    <plugins>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.7.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.ink.FlinkLambdaTest.FlinkToLambda</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>

<dependencies>
    <dependency>
      <groupId>org.apache.flink</groupId>
      <artifactId>flink-table_2.10</artifactId>
      <version>1.3.2</version>
    </dependency>

    <dependency>
      <groupId>org.apache.flink</groupId>
      <artifactId>flink-java</artifactId>
      <version>1.3.2</version>
    </dependency>
    <dependency>
      <groupId>org.apache.flink</groupId>
      <artifactId>flink-streaming-java_2.10</artifactId>
      <version>1.3.2</version>
    </dependency>
    <dependency>
      <groupId>org.apache.flink</groupId>
      <artifactId>flink-clients_2.10</artifactId>
      <version>1.3.2</version>
    </dependency>

    <dependency>
      <groupId>org.apache.flink</groupId>
      <artifactId>flink-scala_2.10</artifactId>
      <version>1.3.2</version>
    </dependency>

    <dependency>
      <groupId>org.apache.flink</groupId>
      <artifactId>flink-streaming-scala_2.10</artifactId>
      <version>1.3.2</version>
    </dependency>

    </dependencies>

一定要把主课改成你的。

jbose2ul

jbose2ul3#

在grad尔:

buildscript {
    repositories {
        maven {
            url 'https://plugins.gradle.org/m2/'
        }
    }
    dependencies {
        classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.4'
    }
}
apply plugin: 'com.github.johnrengelman.shadow'

然后,在汇总akka从属关系的项目中:

shadowJar {
    include 'reference.conf'
}

有了它,您应该能够正常地构建(例如,通过调用组装和构建任务)。
intellij idea也支持这一点。ftw!它还支持下面的sbt构造。

lazy val assemblySettings = Seq(
  assemblyJarName in assembly := name.value + ".jar",
  assemblyMergeStrategy in assembly := {
    case PathList("META-INF", xs @ _*) => MergeStrategy.discard
    case _ => MergeStrategy.first
  })
tct7dpnv

tct7dpnv4#

您需要在pom->maven shaded plugin->configuration部分添加以下代码:

<transformers>
    <!-- append default configs -->
    <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
        <resource>reference.conf</resource>
    </transformer>
</transformers>
66bbxpm5

66bbxpm55#

这可能来得有点晚,但下面是来自flink网站关于这个主题的答案。
此外,还排除了有关meta inf文件夹的信息,这可能会导致在使用jar时出现安全问题。

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-shade-plugin</artifactId>
            <version>3.0.0</version>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>shade</goal>
                    </goals>
                    <configuration>
                        <artifactSet>
                            <excludes>
                                <exclude>com.google.code.findbugs:jsr305</exclude>
                                <exclude>org.slf4j:*</exclude>
                                <exclude>log4j:*</exclude>
                            </excludes>
                        </artifactSet>
                        <filters>
                            <filter>
                                <!-- Do not copy the signatures in the META-INF folder.
                                Otherwise, this might cause SecurityExceptions when using the JAR. -->
                                <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.ManifestResourceTransformer">
                                <mainClass>my.programs.main.clazz</mainClass>
                            </transformer>
                        </transformers>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

相关问题