【发布时间】:2017-05-28 03:46:52
【问题描述】:
我的项目结构如下:
我的Test1.java是这样的:
package TestNG;
import org.testng.annotations.Test;
import com.google.inject.Inject;
import com.google.inject.name.Named;
public class Test1 {
@Inject
@Named("semi-auto.firstname")
String firstname;
@Test
public void test() {
System.out.println(firstname);
}
}
而我的 semi-auto.properties 是
semi-auto.firstname=John
semi-auto.lastname=Doe
我想要做的是使用 Guice 在 Test1 中使用 'firstname' 参数值。 测试通过,但通过的值为 null。 我不能这样吗? 请帮忙
【问题讨论】:
标签: java guice dependency-properties