2 ahllahll ahllahll 于 2013.12.18 21:54 提问

Spring , spark 构架使用了不同的cglib, 但是我需要在项目中同时使用它们

问题是, 我怎样在这个项目中, 按需要生成不同版本的 cglib类, 同时兼容2个构架.

maven

<dependency>
    <groupId>com.commons.algorithm</groupId>
    <artifactId>simulator</artifactId>
    <version>1.0</version>
</dependency>
<dependency> spring works with this
    <groupId>cglib</groupId>
    <artifactId>cglib</artifactId>
    <version>2.2.2</version>
</dependency>
<!--dependency> spark requires this
    <groupId>cglib</groupId>
    <artifactId>cglib</artifactId>
    <version>3.0</version>
</dependency-->
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-core</artifactId>
    <version>3.1.2.RELEASE</version>
</dependency>
<dependency> 
    <groupId>org.apache.spark</groupId>
    <artifactId>spark-core_2.9.3</artifactId>
    <version>0.8.0-incubating</version>
    <type>jar</type>
</dependency>

代码:

@SparkParameter(taskJarLocation = {"analysis/1.0/analysis-1.0.jar"})
@SparkCassandraParameter (keySpace="commons10", port = 9160)
@RunWith(value = Parameterized.class)
public class PerformanceExecutor {
private Simulator simulator;
private Analysis analysis;
private Algorithm algorithm;

public PerformanceExecutor(Simulator simulator, Analysis analysis, Algorithm algorithm){
    this.simulator = simulator;
    this.analysis = analysis;
    this.algorithm = algorithm;
}

@Parameters
public static Collection<Object[]> data() throws ClassNotFoundException, IOException {
    ApplicationContext ctx = new AnnotationConfigApplicationContext(TestConfiguration.class);
    CommonDao commonDao = ctx.getBean(CommonDao.class);
    OpinionDao opinionDao = ctx.getBean(OpinionDao.class);
    DataBaseAdaptor adaptor = new DataBaseAdaptorImpl(opinionDao, commonDao, 1);
    SparkRddHelper helper = new SparkRddHelper();
    Object[][] data = new Object[][]{{new RegisterSimulation(), new CommonRelationAnalysisTask(helper), new CommonRenewAlgorithm(adaptor)}};
    return Arrays.asList(data);
}

@Test
public void pushTest() throws Exception {
    simulator.start("src/main/resources/userCreated/users2.txt", 10); // <-- spring required
    analysis.runAnalysis(); // <-- spark required
    algorithm.process();
}

}

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!