我正在使用类型安全应用程序conf在我的scala项目中提供所有外部connfig,但是在尝试使用<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>${maven.shade.plugin.version}</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>test.myproj.DQJobTrigger</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
创建带阴影的Jar并运行它时以某种方式将conf包装在jar本身中,这在更改值时无法覆盖在应用程序conf。
ConfigFactory
当我尝试从应用程序conf本身加载所有配置时,我不确定该行为。使用trait Config {
private val dqConfig = System.getenv("CONF_PATH")
private val config = ConfigFactory.parseFile(new File(dqConfig))
private val sparkConfig = config.getConfig("sparkConf")
private val sparkConfig = config.getConfig("mysql")
}
sparkConf = {
master = "yarn-client"
}
mysql = {
url = "jdbc:mysql://127.0.0.1:3306/test"
user = "root"
password = "MyCustom98"
driver = "com.mysql.jdbc.Driver"
connectionPool = disabled
keepAliveConnection = true
}
当CONF_PATH被设置为运行jar时application.conf存在的路径。
application.conf
CMD + R
所以现在即使我在应用程序配置中更改属性仍然需要包装罐子时出现的配置。