eclipse IDE导入无法解决错误

时间:2014-04-05 07:38:58

标签: eclipse spring import jamon

我正在使用eclipse IDE构建一个Spring项目,它标识模块的执行时间,为了得到我正在使用的jamonapi.monitorfactory,我在项目构建中添加了外部jamonapi-all.jar,但仍然我得到import com.jamonapi .monitor cannot be resolved error

 package com.blog.samples.aop;

 import java.util.Date;
 import org.aspectj.lang.JoinPoint;
 import org.aspectj.lang.annotation.After;
 import org.aspectj.lang.annotation.Aspect;
 import org.aspectj.lang.annotation.Before;
 import org.apache.log4j.Logger;

 import com.jamonapi.Monitor;
 import com.jamonapi.MonitorFactory;


 @Aspect
 public class PerformanceMonitor
 {
private static final Logger logger_c = Logger.getLogger(PerformanceMonitor.class);
private final String MONITOR = "PERFORMANCE_MONITOR";
private Monitor monitor_i;


@Before("execution(*com.blog.samples.aop.CalculationService.dummyServiceMethod())")
public void startMonitor()
{
    monitor_i = MonitorFactory.start(MONITOR);
}


@After("execution(*com.blog.samples.aop.CalculationService.dummyServiceMethod())")
public void stopMonitor()
{
    monitor_i.stop();
}

public Date getLastAccess()
{
    return monitor_i.getLastAccess();
}

public int getCallCount()
{
    return (int) monitor_i.getHits();
}

public double getAverageCallTime()
{
    return monitor_i.getAvg() / 1000;
}

public double getLastCallTime()
{
    return monitor_i.getLastValue() / 1000;
}

public double getMaximumCallTime()
{
    return monitor_i.getMax() / 1000;
}

public double getMinimumCallTime()
{
    return monitor_i.getMin() / 1000;
}
public double getTotalCallTime()
{
    return monitor_i.getTotal() / 1000;
}

@After("execution(*com.blog.samples.aop.CalculationService.dummyServiceMethod())")
public void log(JoinPoint joinPoint_p)
{
    StringBuffer sb = new StringBuffer();

    sb.append("\n");
    sb.append("*======================================");
    sb.append("\n");
    sb.append("*       PERFORMANCE STATISTICS        *");
    sb.append("\n");
    sb.append("*======================================");
    sb.append("\n");
    sb.append("*  Method Name: " + joinPoint_p.getSignature().getName());
    sb.append("\n");
    sb.append("*  Execution Date: ").append(this.getLastAccess());
    sb.append("\n");
    sb.append("*  Last Execution Time:  ").append(this.getLastCallTime()).append(" sec");
    sb.append("\n");
    sb.append("*  Service Calls: ").append(((this.getCallCount())));
    sb.append("\n");
    sb.append("*  Avg Execution Time: ").append(this.getAverageCallTime()).append(" sec");
    sb.append("\n");
    sb.append("* TotalExecutionTIme:").append(this.getTotalCallTime()).append(" sec");
    sb.append("\n");
    sb.append("* MinExecutionTime:").append(this.getMinimumCallTime()).append(" sec");
    sb.append("\n");
    sb.append("*  Max Execution Time: ").append(this.getMaximumCallTime()).append(" sec");
    sb.append("\n");
    sb.append("*======================================");

    logger_c.info(sb.toString());
}

2 个答案:

答案 0 :(得分:0)

正确导入是这样的:


    import org.jamon.api.*;

但是,在该软件包中找不到那个Monitor类。

答案 1 :(得分:0)

  • jamonapi-all.jar不是包含jamon类的jar。
  • 你想要的是 jamon-2.75.jar 。它应该在jamonapi-all.jar中,或者通过http://www.jamonapi.com
  • 获得
  • 另外,您可以使用jamon的maven依赖,您可以从JAMon网站获取。