修改pom, 修改服务器启动方式,改为代码而不是web.xml
parent
cf9207aaae
commit
85a8c09b24
37
pom.xml
37
pom.xml
|
|
@ -7,8 +7,13 @@
|
|||
<groupId>cn.cloudowr</groupId>
|
||||
<artifactId>dict</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<packaging>war</packaging>
|
||||
<packaging>jar</packaging>
|
||||
<build>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>${basedir}/src/main/webapp</directory>
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
|
|
@ -53,6 +58,19 @@
|
|||
<mainClass>cn.cloudowr.dict.Main</mainClass>
|
||||
</configuration>
|
||||
</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>
|
||||
</build>
|
||||
<dependencies>
|
||||
|
|
@ -62,10 +80,21 @@
|
|||
<version>3.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.jfinal</groupId>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-server</artifactId>
|
||||
<version>8.1.8</version>
|
||||
<version>9.4.1.v20170120</version>
|
||||
</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>-->
|
||||
<!--<groupId>mysql</groupId>-->
|
||||
<!--<artifactId>mysql-connector-java</artifactId>-->
|
||||
|
|
@ -85,8 +114,6 @@
|
|||
<groupId>cn.cloudowr</groupId>
|
||||
<artifactId>sdk</artifactId>
|
||||
<version>1.4.16</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${basedir}/lib/sdk-1.4.16.jar</systemPath>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
@ -1,7 +1,13 @@
|
|||
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;
|
||||
|
||||
/**
|
||||
|
|
@ -15,10 +21,25 @@ public class Main {
|
|||
public static int port;
|
||||
public static String dabaseName;
|
||||
private static int AppPort;
|
||||
public static void main(String[] args) {
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
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 {
|
||||
Properties pro = new Properties();
|
||||
|
|
|
|||
|
|
@ -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