Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/348.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 在Guice注入中加载diff属性文件会引发错误_Java_Testng_Appium_Guice - Fatal编程技术网

Java 在Guice注入中加载diff属性文件会引发错误

Java 在Guice注入中加载diff属性文件会引发错误,java,testng,appium,guice,Java,Testng,Appium,Guice,我正在尝试加载其他属性文件。基于testng选项。更新和加载属性名称时引发以下错误。请查找完整的日志跟踪以供参考 com.google.common.util.concurrent.UncheckedExecutionException: java.lang.IllegalArgumentException at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2217) at com.google.c

我正在尝试加载其他属性文件。基于testng选项。更新和加载属性名称时引发以下错误。请查找完整的日志跟踪以供参考

com.google.common.util.concurrent.UncheckedExecutionException: java.lang.IllegalArgumentException
    at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2217)
    at com.google.common.cache.LocalCache.get(LocalCache.java:4154)
    at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:4158)
    at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:5147)
    at com.google.common.cache.LocalCache$LocalLoadingCache.getUnchecked(LocalCache.java:5153)
    at com.google.inject.internal.util.StackTraceElements.forMember(StackTraceElements.java:71)
    at com.google.inject.internal.Messages.formatParameter(Messages.java:282)
    at com.google.inject.internal.Messages.formatInjectionPoint(Messages.java:273)
    at com.google.inject.internal.Messages.formatSource(Messages.java:229)
    at com.google.inject.internal.Messages.formatSource(Messages.java:220)
    at com.google.inject.internal.Messages.formatMessages(Messages.java:90)
    at com.google.inject.ConfigurationException.getMessage(ConfigurationException.java:73)
    at org.testng.internal.ConfigInvoker.handleConfigurationFailure(ConfigInvoker.java:423)
    at org.testng.internal.ConfigInvoker.invokeConfigurations(ConfigInvoker.java:300)
    at org.testng.TestRunner.invokeTestConfigurations(TestRunner.java:623)
    at org.testng.TestRunner.beforeRun(TestRunner.java:613)
    at org.testng.TestRunner.run(TestRunner.java:584)
    at org.testng.SuiteRunner.runTest(SuiteRunner.java:402)
    at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:396)
    at org.testng.SuiteRunner.privateRun(SuiteRunner.java:355)
    at org.testng.SuiteRunner.run(SuiteRunner.java:304)
    at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:53)
    at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:96)
    at org.testng.TestNG.runSuitesSequentially(TestNG.java:1180)
    at org.testng.TestNG.runSuitesLocally(TestNG.java:1102)
    at org.testng.TestNG.runSuites(TestNG.java:1032)
    at org.testng.TestNG.run(TestNG.java:1000)
    at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:115)
    at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
    at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)
Caused by: java.lang.IllegalArgumentException
    at com.google.inject.internal.asm.$ClassReader.<init>(ClassReader.java:160)
    at com.google.inject.internal.asm.$ClassReader.<init>(ClassReader.java:143)
    at com.google.inject.internal.asm.$ClassReader.<init>(ClassReader.java:418)
    at com.google.inject.internal.util.LineNumbers.<init>(LineNumbers.java:64)
    at com.google.inject.internal.util.StackTraceElements$1.load(StackTraceElements.java:49)
    at com.google.inject.internal.util.StackTraceElements$1.load(StackTraceElements.java:45)
    at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3716)
    at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2424)
    at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2298)
    at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2211)
    ... 29 more
使用PropertiesModule加载属性文件

public class PropertiesModule extends AbstractModule {

    public static String env1;
    protected void configure(String env) {
        System.out.println("PropertiesModule is done"+env);
        env1 = env;

    }
    @Override
    protected void configure() {
        try {
            System.out.println("PropertiesModule is done"+env1);
            Properties props = new Properties();
            System.out.println("PropertiesModule is done");
            props.load(new FileInputStream(System.getProperty("user.dir")+env1));
            Names.bindProperties(binder(), props);
        } catch (IOException e) {
            e.printStackTrace();
            Assert.fail("Property File Not Loaded!");
        }

    }
当我使用不同的属性值运行时。我得到了上面的a例外

基类

    @BeforeSuite(alwaysRun = true)
    @Parameters({"environment"})
    public void setUp(@Optional("local") String environment) throws ClassNotFoundException, SQLException, IOException, IllegalAccessException {
        Invoke.initializeVariables(environment);
    }

    @BeforeTest
    public void setup() throws Exception, DriverNotInitializedException {
        initBrowserAndNavigate();

    }


请查找上面的代码片段。

您能否发布堆栈跟踪的其余部分,包括顶部错误和
之后的跟踪/消息,原因是:java.lang.IllegalArgumentException
?@ColinAlworth使用完整的日志跟踪更新了帖子至少第一行仍然缺失-另外,您能否共享加载属性文件的方式,你的模块,你的测试?@ColinAlworth-更新你能检查一下它是否清晰吗?谢谢-这对我个人来说没有帮助,但问题更容易理解,希望这能帮助其他人回答。你能发布堆栈跟踪的其余部分吗,顶部错误和
后的跟踪/消息都是由以下原因引起的:java.lang.IllegalArgumentException
?@ColinAlworth使用完整的日志跟踪更新了帖子,至少第一行仍然缺失-另外,您可以分享如何加载属性文件、模块、,你的测试?@ColinAlworth-更新了-你能检查一下它是否清晰吗?谢谢-这对我个人来说没有帮助,但是这个问题更容易理解,希望这能帮助其他人回答。
    @BeforeSuite(alwaysRun = true)
    @Parameters({"environment"})
    public void setUp(@Optional("local") String environment) throws ClassNotFoundException, SQLException, IOException, IllegalAccessException {
        Invoke.initializeVariables(environment);
    }

    @BeforeTest
    public void setup() throws Exception, DriverNotInitializedException {
        initBrowserAndNavigate();

    }