手动注入Spring环境

        ApplicationContext 
        context = new FileSystemXmlApplicationContext(
                "src/main/webapp/WEB-INF/mvc-dispatcher-servlet.xml");
        
        
        MahoutServiceImpl impl = (MahoutServiceImpl)context.getBean(MahoutServiceImpl.class); 
        System.out.println(impl.JARS);
        
        BasicConfig basicConfig = context.getBean(BasicConfig.class); 
        HadoopService hadoopService = context.getBean(HadoopService.class); 
        
        Configuration conf = basicConfig.config();
        {
            String inPath = "hdfs://c0004649.itcs.hp.com:9000/user/hdfs/userDoc/uuid_001/";
            String outPath = "hdfs://c0004649.itcs.hp.com:9000/user/hdfs/userDoc/uuid_001/result/";
            String tmpPath =  "hdfs://c0004649.itcs.hp.com:9000/tmp/rec001/001";
            String similarityMatrixPath = "hdfs://c0004649.itcs.hp.com:9000/user/hdfs/userDoc/uuid_001/similarityResult/";
            try {
                hadoopService.copyFilesToHDFS("/localfile/item.csv", inPath);
                impl.Item_based_CF_With_PearsonCorrelationSimilarity(conf, inPath, outPath, tmpPath, similarityMatrixPath);
            } catch (TasteException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

你可能感兴趣的:(java)