自动环境PropertySourcesPlaceholder始终为null

时间:2015-07-12 06:51:35

标签: spring null autowired environment

dfs(Vertex start){
    Stack<Vertex> stack = new Stack<>(); // initialize a stack
    List<Vertex> visited = new ArrayList<>();//maintains order of visited nodes
    stack.push(start); // push the start
    while(!stack.isEmpty()){ //check if stack is empty
        Vertex popped = stack.pop(); // pop the top of the stack
        if(!visited.contains(popped)){ //backtrack if the vertex is already visited
            visited.add(popped); //mark it as visited as it is not yet visited
            for(Vertex adjacent: popped.getAdjacents()){ //get the adjacents of the vertex as add them to the stack
                    stack.add(adjacent);
            }
        }
    }

    for(Vertex v1 : visited){
        System.out.println(v1.getId());
    }
}

platformVersion和environment始终为null。 在日志中:添加[class path resource [tests.properties]] PropertySource,搜索优先级最低。 我在stackoverflow(Autowired Environment is null)上看到了其他帖子,我不想继续实现EnvironmentAware。 将环境私有化改为公共环境并不能解决问题。 欢迎任何其他想法!

1 个答案:

答案 0 :(得分:0)

环境为空,因为我使用自定义测试范围(有关详细信息,请参阅此帖子https://peterkedemo.wordpress.com/2013/03/30/writing-good-selenium-tests-with-page-objects-and-spring/)。删除范围后,环境注入良好。你有什么想法吗?