import com.dev.energy.client.utils.StringUtils; import org.apache.log4j.Logger; import org.apache.log4j.PropertyConfigurator; import org.mortbay.http.SocketListener; import org.mortbay.jetty.Server; public class AjaxJettyLauncher { protected int port = 8080; protected String contextName = "zwwms"; protected String deployPath = null; private static Logger logger = Logger.getLogger(AjaxJettyLauncher.class); public static void main(String[] args) throws Exception { String currentDir = System.getProperty("user.dir"); System.out.println("当前根目录是: " + currentDir); PropertyConfigurator.configure("log4j.properties"); AjaxJettyLauncher jl = new AjaxJettyLauncher(); jl.run(); } protected void init() { } protected void run() throws Exception { Server server = new Server(); SocketListener listener = new SocketListener(); listener.setPort(getPort()); server.addListener(listener); server.addWebApplication("/" + getContextName() , getDeployPath()); server.start(); logger.error("1232221231"); } protected int getPort() { return port; } protected String getContextName() { return contextName; } protected String getDeployPath() { if (StringUtils.isEmpty(deployPath)) { deployPath = "./target/" + contextName + "/"; } return deployPath; } }