我正在尝试使用NetBeans在java maven项目中实现akka。当我从NetBeans运行它时运行正常但是当我从NetBeans运行runnable jar时,它会生成错误。
Exception in thread "main" com.typesafe.config.ConfigException$Missing: No configuration setting found for key 'akka.remote.log-received-messages'
当我在配置中添加log-received-message时,它会要求另一个配置。这是我用来生成jar文件的插件。
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
</plugin>
我的依赖是
<dependency>
<groupId>com.typesafe.akka</groupId>
<artifactId>akka-actor_2.10</artifactId>
<version>2.3.7</version>
</dependency>
<dependency>
<groupId>com.typesafe.akka</groupId>
<artifactId>akka-remote_2.10</artifactId>
<version>2.3.7</version>
</dependency>
akka的配置是
akka10300{
akka{
actor{provider = "akka.remote.RemoteActorRefProvider"}
remote {
enabled-transports = ["akka.remote.netty.tcp"]
netty.tcp {
hostname="127.0.0.1"
port=10300
}
}
}
}
答案 0 :(得分:7)
有一个关于在http://doc.akka.io/docs/akka/snapshot/general/configuration.html从“胖罐子”运行Akka的警告。问题是有多个reference.conf
配置文件,Maven程序集或树荫插件的默认行为是用以后的实例覆盖配置文件的早期实例。
要解决此问题,建议的方法是使用Maven shade插件生成可执行jar并将其配置为将所有resource.conf
文件附加到单个文件中而不是覆盖。建议的Maven shade插件配置如下:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<shadedArtifactAttached>true</shadedArtifactAttached>
<shadedClassifierName>allinone</shadedClassifierName>
<artifactSet>
<includes>
<include>*:*</include>
</includes>
</artifactSet>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>reference.conf</resource>
</transformer>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<manifestEntries>
<Main-Class>akka.Main</Main-Class>
</manifestEntries>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>