修改pom, 修改服务器启动方式,改为代码而不是web.xml
parent
cf9207aaae
commit
85a8c09b24
37
pom.xml
37
pom.xml
|
|
@ -7,8 +7,13 @@
|
||||||
<groupId>cn.cloudowr</groupId>
|
<groupId>cn.cloudowr</groupId>
|
||||||
<artifactId>dict</artifactId>
|
<artifactId>dict</artifactId>
|
||||||
<version>1.0-SNAPSHOT</version>
|
<version>1.0-SNAPSHOT</version>
|
||||||
<packaging>war</packaging>
|
<packaging>jar</packaging>
|
||||||
<build>
|
<build>
|
||||||
|
<resources>
|
||||||
|
<resource>
|
||||||
|
<directory>${basedir}/src/main/webapp</directory>
|
||||||
|
</resource>
|
||||||
|
</resources>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
|
@ -53,6 +58,19 @@
|
||||||
<mainClass>cn.cloudowr.dict.Main</mainClass>
|
<mainClass>cn.cloudowr.dict.Main</mainClass>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-assembly-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<archive>
|
||||||
|
<manifest>
|
||||||
|
<mainClass>cn.cloudowr.dict.Main</mainClass>
|
||||||
|
</manifest>
|
||||||
|
</archive>
|
||||||
|
<descriptorRefs>
|
||||||
|
<descriptorRef>jar-with-dependencies</descriptorRef>
|
||||||
|
</descriptorRefs>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
@ -62,10 +80,21 @@
|
||||||
<version>3.0</version>
|
<version>3.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.jfinal</groupId>
|
<groupId>org.eclipse.jetty</groupId>
|
||||||
<artifactId>jetty-server</artifactId>
|
<artifactId>jetty-server</artifactId>
|
||||||
<version>8.1.8</version>
|
<version>9.4.1.v20170120</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.eclipse.jetty</groupId>
|
||||||
|
<artifactId>jetty-servlet</artifactId>
|
||||||
|
<version>9.4.1.v20170120</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.eclipse.jetty</groupId>
|
||||||
|
<artifactId>jetty-webapp</artifactId>
|
||||||
|
<version>9.4.1.v20170120</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!--<dependency>-->
|
<!--<dependency>-->
|
||||||
<!--<groupId>mysql</groupId>-->
|
<!--<groupId>mysql</groupId>-->
|
||||||
<!--<artifactId>mysql-connector-java</artifactId>-->
|
<!--<artifactId>mysql-connector-java</artifactId>-->
|
||||||
|
|
@ -85,8 +114,6 @@
|
||||||
<groupId>cn.cloudowr</groupId>
|
<groupId>cn.cloudowr</groupId>
|
||||||
<artifactId>sdk</artifactId>
|
<artifactId>sdk</artifactId>
|
||||||
<version>1.4.16</version>
|
<version>1.4.16</version>
|
||||||
<scope>system</scope>
|
|
||||||
<systemPath>${basedir}/lib/sdk-1.4.16.jar</systemPath>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
|
@ -1,7 +1,13 @@
|
||||||
package cn.cloudowr.dict;
|
package cn.cloudowr.dict;
|
||||||
|
|
||||||
import com.jfinal.core.JFinal;
|
import com.jfinal.core.JFinalFilter;
|
||||||
|
import org.eclipse.jetty.server.Server;
|
||||||
|
import org.eclipse.jetty.servlet.FilterHolder;
|
||||||
|
import org.eclipse.jetty.webapp.WebAppContext;
|
||||||
|
|
||||||
|
import javax.servlet.DispatcherType;
|
||||||
|
import java.io.*;
|
||||||
|
import java.util.EnumSet;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -15,21 +21,36 @@ public class Main {
|
||||||
public static int port;
|
public static int port;
|
||||||
public static String dabaseName;
|
public static String dabaseName;
|
||||||
private static int AppPort;
|
private static int AppPort;
|
||||||
public static void main(String[] args) {
|
|
||||||
|
public static void main(String[] args) throws IOException {
|
||||||
read();
|
read();
|
||||||
JFinal.start("src/main/webapp", AppPort, "/");
|
EnumSet<DispatcherType> all = EnumSet.of(DispatcherType.ASYNC, DispatcherType.ERROR,
|
||||||
|
DispatcherType.FORWARD, DispatcherType.INCLUDE, DispatcherType.REQUEST);
|
||||||
|
final Server server = new Server(AppPort);
|
||||||
|
try {
|
||||||
|
WebAppContext context = new WebAppContext("/", "/");
|
||||||
|
FilterHolder filter = new FilterHolder(new JFinalFilter());
|
||||||
|
filter.setInitParameter("configClass", "cn.cloudowr.dict.Config");
|
||||||
|
context.addFilter(filter, "/*", all);
|
||||||
|
server.setHandler(context);
|
||||||
|
server.start();
|
||||||
|
server.join();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
public static void read(){
|
|
||||||
try{
|
public static void read() {
|
||||||
|
try {
|
||||||
Properties pro = new Properties();
|
Properties pro = new Properties();
|
||||||
pro.load(Config.class.getResourceAsStream("/config.properties"));
|
pro.load(Config.class.getResourceAsStream("/config.properties"));
|
||||||
username = pro.getProperty("username");
|
username = pro.getProperty("username");
|
||||||
database = pro.getProperty("database");
|
database = pro.getProperty("database");
|
||||||
password = pro.getProperty("password");
|
password = pro.getProperty("password");
|
||||||
host = pro.getProperty("host");
|
host = pro.getProperty("host");
|
||||||
port = Integer.parseInt(pro.getProperty("port"));
|
port = Integer.parseInt(pro.getProperty("port"));
|
||||||
dabaseName = pro.getProperty("dabaseName");
|
dabaseName = pro.getProperty("dabaseName");
|
||||||
AppPort = Integer.parseInt(pro.getProperty("AppPort"));
|
AppPort = Integer.parseInt(pro.getProperty("AppPort"));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
System.exit(0);
|
System.exit(0);
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
|
||||||
|
version="3.1">
|
||||||
|
<filter>
|
||||||
|
<filter-name>cn.cloudowr.dict</filter-name>
|
||||||
|
<filter-class>com.jfinal.core.JFinalFilter</filter-class>
|
||||||
|
<init-param>
|
||||||
|
<param-name>configClass</param-name>
|
||||||
|
<param-value>cn.cloudowr.dict.Config</param-value>
|
||||||
|
</init-param>
|
||||||
|
</filter>
|
||||||
|
<filter-mapping>
|
||||||
|
<filter-name>cn.cloudowr.dict</filter-name>
|
||||||
|
<url-pattern>/*</url-pattern>
|
||||||
|
</filter-mapping>
|
||||||
|
</web-app>
|
||||||
Loading…
Reference in New Issue