首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何通过Maven将自定义配置文件传递给Akka应用程序?

如何通过Maven将自定义配置文件传递给Akka应用程序?
EN

Stack Overflow用户
提问于 2015-12-09 19:58:01
回答 1查看 482关注 0票数 0

我正在使用Maven开发一个Akka应用程序。为了进行测试,我使用scalatest。当我使用application.conf中的配置运行测试时,一切都很顺利。但当我尝试使用自定义文件时,它就不起作用了(例如,我有一个common.conf和其他文件,其中包括一个用于调整Jenkins时间刻度的文件,等等)。我试着用mvn -Dconfig.file=/path/to/myenv.conf test-Dconfig.resource=/path/to/myenv.conf test运行测试,但是没有成功。我使用的是Akka 2.4.0和Scala 2.11.7。

附注:下面是我的pom.xml中插件的配置

代码语言:javascript
复制
<build>
        <plugins>
            <plugin>
                <groupId>net.alchim31.maven</groupId>
                <artifactId>scala-maven-plugin</artifactId>
                <version>3.2.1</version>
                <executions>
                    <execution>
                        <id>scala-compile</id>
                        <goals>
                            <goal>compile</goal>
                            <goal>testCompile</goal>
                        </goals>
                        <configuration>
                            <args>
                                <!--arg>-make:transitive</arg-->
                                <arg>-dependencyfile</arg>
                                <arg>${project.build.directory}/.scala_dependencies</arg>
                            </args>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <!-- disable surefire -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.7</version>
                <configuration>
                    <skipTests>true</skipTests>
                </configuration>
            </plugin>
            <!-- enable scalatest -->
            <plugin>
                <groupId>org.scalatest</groupId>
                <artifactId>scalatest-maven-plugin</artifactId>
                <version>1.0</version>
                <configuration>
                    <reportsDirectory>${project.build.directory}/surefire-reports</reportsDirectory>
                    <stdout>W</stdout>
                    <!-- Skip coloring output -->
                    <junitxml>.</junitxml>
                </configuration>
                <executions>
                    <execution>
                        <id>scala-test</id>
                        <goals>
                            <goal>test</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

非常感谢!

EN

回答 1

Stack Overflow用户

发布于 2015-12-09 20:04:29

好吧,我实际上找到了一种方法,只是将这个添加到我最具伸缩性的maven插件中:

代码语言:javascript
复制
<argLine>-Dconfig.resource=/local.conf</argLine>

有没有办法把它从外部传递给mvn test

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/34178274

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档