关于eclipst的一点问题 我在eclipse中引进了一个新工程.但当我写了一个测试类运行的时候为什么显示找不到"main"方法.错误提示为:"The selection does not contain a main type" 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 RUN 的下拉选项里选 RUN AS JUNIT public class Main { /** * Logger for this class */ private static final Logger logger = Logger.getLogger(Main.class); private static ApplicationContext applicationContext; /** * @param args */ public static void main(String[] args) { // 输出系统日志 logger.error("netkeeper 系统开始初始化 >>>>>>"); // 初始化配置管理器 ConfigUtil.init("netkeeper.xml"); DESUtil.init(); // 初始化spring applicationContext = new ClassPathXmlApplicationContext(new String[] { "register_server_datasource.xml", "business-definition.xml","timer-task.xml" }); // 启动客户端注册监听器 ServerListener.listen(); ClientServerBean clientManager = new ClientServerBean(); ContainerMonitor cacheMinitor = new ContainerMonitor(); try { clientManager.registeMySelf(); cacheMinitor.registeMySelf(); } catch (JMException e) { e.printStackTrace(); } // 输出系统日志 logger.error("netkeeper 系统开始初始化完毕 <<<<<<"); } public static ApplicationContext getApplicationContext() { return applicationContext; }} 首先这个类要继承 junit.framework.TestCase 其次把JUNIT类库加载到你的CLASSPATH然后运行 RUN AS JUNIT 程序应该没社么问题,看看CLASSPATH是否设好了,有没有加载到第三方的JAR和XML文件 我晕啊~~为什么把类加进来了还是找不到main http://www.56dao.com:80//regnew.bbscs?rec=76695 测试代码写上来据我观察楼主没用junit 遇到过这个问题,你可以试试这个方法: eclipse 工具框最右边,选择java模试。再试试 javabean的打包问题 为什么我在cmd里运行javac welcome.java 没显示/这是你的第一个程序,欢迎你走入Java的大门 请问这个功能怎么实现? 请问窗体改变大小的时候会触发什么事件啊 如何用Java将一个整数串编码成一个二进制串 Java 中如何实现文件分割? 一个比较弱的输出问题!请帮忙!谢了! 1780518的打印程序(大家有什么好玩的一起贴阿) 写入到xml文件的排版问题 Apusic2.0在官方网上无法下载??? Resin的官方网站好像出了问题? 做串口通讯,求javax.comm的windows包,从sun上没有找到windows的
/**
* Logger for this class
*/
private static final Logger logger = Logger.getLogger(Main.class); private static ApplicationContext applicationContext; /**
* @param args
*/
public static void main(String[] args) {
// 输出系统日志
logger.error("netkeeper 系统开始初始化 >>>>>>");
// 初始化配置管理器
ConfigUtil.init("netkeeper.xml");
DESUtil.init();
// 初始化spring
applicationContext = new ClassPathXmlApplicationContext(new String[] {
"register_server_datasource.xml",
"business-definition.xml","timer-task.xml" });
// 启动客户端注册监听器
ServerListener.listen();
ClientServerBean clientManager = new ClientServerBean();
ContainerMonitor cacheMinitor = new ContainerMonitor();
try {
clientManager.registeMySelf();
cacheMinitor.registeMySelf();
} catch (JMException e) {
e.printStackTrace();
}
// 输出系统日志
logger.error("netkeeper 系统开始初始化完毕 <<<<<<");
} public static ApplicationContext getApplicationContext() {
return applicationContext;
}}
然后运行 RUN AS JUNIT
eclipse 工具框最右边,选择java模试。再试试