Преглед изворни кода

增加kmall-schedule打包为war包

csk пре 6 година
родитељ
комит
bc5edb4502

+ 8 - 13
kmall-manager/src/main/java/com/kmall/manager/manager/redis/JedisUtil.java

@@ -30,24 +30,19 @@ public class JedisUtil implements Serializable {
 
         try {
             if (null == JedisPropertiesBuilder.instance()) {
-                logger.error("jedis is not work......");
+                logger.error("jedis init is error.");
+                throw new Exception("jedis init is error.");
             }
 
             JedisProperties jp = JedisPropertiesBuilder.instance();
-            logger.debug("1:" + jp.getPool().getMaxIdle());
-            logger.debug("2:" + jp.getPool().getMaxWait());
-            logger.debug("3:" + jp.getPool().getMaxTotal());
-            logger.debug("4:" + jp.getPool().getTestOnBorrow());
-            logger.debug("5:" + jp.getHost());
-            logger.debug("6:" + jp.getPort());
 
-            config.setMaxIdle(Integer.parseInt(JedisPropertiesBuilder.instance().getPool().getMaxIdle()));
+            config.setMaxIdle(Integer.parseInt(jp.getPool().getMaxIdle()));
 
-            config.setMaxWaitMillis(Long.parseLong(JedisPropertiesBuilder.instance().getPool().getMaxWait()));
-            config.setMaxTotal(Integer.parseInt(JedisPropertiesBuilder.instance().getPool().getMaxTotal()));
-            config.setTestOnBorrow(Boolean.parseBoolean(JedisPropertiesBuilder.instance().getPool().getTestOnBorrow()));
-            String redisIp = JedisPropertiesBuilder.instance().getHost();
-            int port = Integer.parseInt(JedisPropertiesBuilder.instance().getPort());
+            config.setMaxWaitMillis(Long.parseLong(jp.getPool().getMaxWait()));
+            config.setMaxTotal(Integer.parseInt(jp.getPool().getMaxTotal()));
+            config.setTestOnBorrow(Boolean.parseBoolean(jp.getPool().getTestOnBorrow()));
+            String redisIp = jp.getHost();
+            int port = Integer.parseInt(jp.getPort());
             jedisPool = new JedisPool(config, redisIp, port, 10000);
 
             logger.info("redis连接成功: {}:{}, ", redisIp, port);

+ 23 - 2
kmall-schedule/pom.xml

@@ -89,10 +89,10 @@
                 </executions>
             </plugin>
 
-            <!-- 打包可执行jar的方法一 -->
+            <!-- 打包可执行jar -->
             <!-- 无依赖其他任何jar -->
             <!-- 打包jar文件时,配置manifest文件,加入lib包的jar依赖 -->
-            <plugin>
+            <!--<plugin>
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-jar-plugin</artifactId>
                 <version>${maven.jar.version}</version>
@@ -106,7 +106,28 @@
                         </manifest>
                     </archive>
                 </configuration>
+            </plugin>-->
+
+
+            <!-- 打包war包 -->
+            <plugin>
+                <artifactId>maven-war-plugin</artifactId>
+                <version>${maven.war.version}</version>
+                <configuration>
+                    <packagingExcludes>WEB-INF/web.xml</packagingExcludes>
+                    <failOnMissingWebXml>false</failOnMissingWebXml>
+                    <warSourceDirectory>src/main/webapp</warSourceDirectory>
+                    <failOnMissingWebXml>false</failOnMissingWebXml>
+                    <webResources>
+                        <resource>
+                            <directory>src/main/resources/conf</directory>
+                            <targetPath>WEB-INF/classes/conf</targetPath>
+                            <filtering>true</filtering>
+                        </resource>
+                    </webResources>
+                </configuration>
             </plugin>
+
         </plugins>
 
     </build>

+ 12 - 0
kmall-schedule/src/main/resources/spring/spring-schedule-main.xml

@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:context="http://www.springframework.org/schema/context"
+       xmlns:task="http://www.springframework.org/schema/task"
+       xsi:schemaLocation="http://www.springframework.org/schema/beans
+        http://www.springframework.org/schema/beans/spring-beans-4.2.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task.xsd">
+
+    <import resource="spring-schedule.xml"/>
+
+
+</beans>

+ 0 - 13
kmall-schedule/src/main/resources/spring/spring-scheduler.xml → kmall-schedule/src/main/resources/spring/spring-schedule.xml

@@ -9,21 +9,8 @@
     <context:component-scan base-package="com.kmall.schedule.**">
     </context:component-scan>
 
-    <!--<context:annotation-config/>-->
-
-    <!--<bean id="placeholderConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
-        <property name="locations">
-            <list>
-                <value>classpath:conf/db.properties</value>
-            </list>
-        </property>
-        <property name="fileEncoding" value="UTF-8"/>
-    </bean>-->
-
-    <!--<import resource="spring-jdbc.xml"/>-->
     <import resource="classpath:spring/spring-manager-main.xml"/>
 
-
     <!--开启这个配置,spring才能识别@Scheduled注解   -->
     <task:annotation-driven scheduler="qbScheduler" mode="proxy"/>
     <task:scheduler id="qbScheduler" pool-size="10"/>

+ 10 - 0
kmall-schedule/src/main/webapp/404.html

@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html lang="zh-CN">
+<head>
+    <meta charset="UTF-8">
+    <title>kmall-schedule</title>
+</head>
+<body>
+    kmall-schedule 404 页面未发现
+</body>
+</html>

+ 54 - 0
kmall-schedule/src/main/webapp/WEB-INF/web.xml

@@ -0,0 +1,54 @@
+<?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" metadata-complete="false">
+
+    <context-param>
+        <param-name>contextConfigLocation</param-name>
+        <param-value>classpath:spring/spring-schedule-main.xml</param-value>
+    </context-param>
+
+    <!--logback 日志-->
+    <context-param>
+        <param-name>logbackConfigLocation</param-name>
+        <param-value>classpath:logback.xml</param-value>
+    </context-param>
+
+    <context-param>
+        <param-name>webAppRootKey</param-name>
+        <param-value>webPath</param-value>
+    </context-param>
+
+    <listener>
+        <listener-class>org.springframework.web.util.WebAppRootListener</listener-class>
+    </listener>
+
+    <listener>
+        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
+    </listener>
+
+
+    <servlet>
+        <servlet-name>dispatcherServlet</servlet-name>
+        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
+        <init-param>
+            <param-name>contextConfigLocation</param-name>
+            <param-value>classpath:spring/spring-schedule-main.xml</param-value>
+        </init-param>
+        <load-on-startup>1</load-on-startup>
+    </servlet>
+    <servlet-mapping>
+        <servlet-name>dispatcherServlet</servlet-name>
+        <!--url-pattern配置为/时,静态文件处理必须采用tomcat的DefaultServlet先于spring的DispatcherServlet处理-->
+        <url-pattern>/</url-pattern>
+    </servlet-mapping>
+
+
+    <error-page>
+        <error-code>404</error-code>
+        <location>/404.html</location>
+    </error-page>
+
+</web-app>

+ 10 - 0
kmall-schedule/src/main/webapp/index.html

@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html lang="zh-CN">
+<head>
+    <meta charset="UTF-8">
+    <title>kmall-schedule</title>
+</head>
+<body>
+    kmall-schedule start
+</body>
+</html>