弹出的错误是“导入无法解析”仅在导入“org.apache.log4j.Logger;”时....这是Main.java 和其他java类有相同的错误...任何人都可以修复或帮助? 这是发送短信
package com.dbs.epodsms;
import com.dbs.epodsms.business.logic.ConfigureModem;
import com.dbs.epodsms.business.logic.SmsProcessor;
import com.dbs.epodsms.business.object.Log;
import com.dbs.epodsms.business.object.Outgoing;
import com.dbs.epodsms.misc.Network;
import java.util.ArrayList;
import java.util.List;
import org.apache.log4j.Logger;
public class Main
{
private static Logger logger = Logger.getLogger(Main.class);
public static void main(String[] args)
{
logger.info("Application started.");
List<Outgoing> outgoingList = new ArrayList<Outgoing>();
SmsProcessor smsProcessor = new SmsProcessor();
try
{
ConfigureModem cfgModem = ConfigureModem.getInstance();
if (!cfgModem.configure())
{
logger.error(cfgModem.getMessage());
logger.error("An error occured while configuring your modem. Please check that your modem is properly installed and that the hw is not defective.");
logger.info("The application will now exit.");
System.exit(0);
}
List<Outgoing> oldOutgoingList = smsProcessor.getOutgoingList(Network.GLOBE);
if (oldOutgoingList.size() > 0)
{
outgoingList.addAll(oldOutgoingList);
}
outgoingList.addAll(smsProcessor.getNewSMS(cfgModem.getGateway()));
logger.info("Processing a total of " + outgoingList.size() + " sms...");
for (Outgoing o : outgoingList)
{
if (o.getRetries() > 3)
{
smsProcessor.sendEmail(o);
}
else if (smsProcessor.sendSMS(o))
{
logger.info("SMS was sent successfully.");
Log log = new Log();
log.setRemarks("REPLY SENT");
log.setSenderNumber(o.getRecipient());
log.setSms(o.getMessage());
smsProcessor.saveToLog(log);
smsProcessor.deleteOutging(o.getId());
}
else
{
logger.error("Error sending message to " + o.getRecipient());
o.setRetries(o.getRetries() + 1);
smsProcessor.addOrUpdateOutgoing(o);
}
}
logger.info("Stopping service...");
cfgModem.stopService();
smsProcessor.closeDBConnection();
System.exit(0);
}
catch (Exception e)
{
logger.error(e.toString());
}
}
}
答案 0 :(得分:0)
确保您的classpath中有log4j Jar文件。在Java项目中,右键单击并选择“Build Path - &gt; Configure Build Path”,然后在libraries选项卡中添加Jar文件。