欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

工具使用 tools 

程序员文章站 2024-03-17 10:53:58
...

1.shell

BEGIN{time=systime()}
{
    if($3 ~ /^\[GC/) {
        gsub(/.*/, "", $1) 
        gsub(/.*/, "", $2) 
        gsub(/.*/, "[GC", $3) 
    }   
    # print $0 >> "gc_fmt_"strftime("%Y-%m-%d", time)".log"
    print $0 >> ARGV[1]"_fmt.log"
}
END{}

 

! /bin/bash

# 数据库参数
USER="xxx"
PASS="xxx"
DB_NAME_START="account"
SHARD_TABLE="user"
DB_NUM=2
SHARD_TABLE_NUM=10
CREATE_TABLES_SQL=""

# 连接数据源
MYSQL_CON="mysql -haccountdb.cgxsivrnp3vr.us-east-1.rds.amazonaws.com -u$USER -p$PASS"

# 创建数据库
#for d in $(seq $DB_NUM)
#do
#       CREATE_TABLES_SQL="$CREATE_TABLES_SQL DROP DATABASE IF EXISTS "$DB_NAME_START"_$d; CREATE DATABASE "$DB_NAME_START"_$d DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;"
#done



# 循环的创建分表
for i in `seq $DB_NUM`
do
        for j in `seq $SHARD_TABLE_NUM`
        do
        CREATE_TABLES_SQL="$CREATE_TABLES_SQL
DROP TABLE IF EXISTS "$DB_NAME_START"_$i."$SHARD_TABLE"_$j;
CREATE TABLE "$DB_NAME_START"_$i."$SHARD_TABLE"_$j (
        id           BIGINT(20) NOT NULL,
        nickname     VARCHAR(40) NOT NULL DEFAULT '',
        username     VARCHAR(64) NOT NULL DEFAULT '',
        password     VARCHAR(64) NOT NULL DEFAULT '',
        status       TINYINT NOT NULL DEFAULT 1,
        type         TINYINT NOT NULL DEFAULT 0,
        question     TINYINT NOT NULL DEFAULT 0,
        anwser       VARCHAR(100) NOT NULL DEFAULT '',
        createTime   DATETIME NOT NULL,
        updateTime   DATETIME NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE UNIQUE INDEX id_index    ON "$DB_NAME_START"_$i."$SHARD_TABLE"_$j(id);
CREATE UNIQUE INDEX name_index  ON "$DB_NAME_START"_$i."$SHARD_TABLE"_$j(username);"
        done
done

#库1中的其他表
CREATE_TABLES_SQL="$CREATE_TABLES_SQL 
DROP TABLE IF EXISTS "$DB_NAME_START"_1.log;
CREATE TABLE "$DB_NAME_START"_1.log (
        id           INT PRIMARY KEY AUTO_INCREMENT,
        username     VARCHAR(40) NOT NULL DEFAULT '',
        action       TINYINT NOT NULL DEFAULT 0,
        channel      VARCHAR(64) NOT NULL DEFAULT '',
        ip           VARCHAR(64)  NOT NULL DEFAULT '',
        type         TINYINT NOT NULL DEFAULT 0,
        version      VARCHAR(64) NOT NULL DEFAULT '',
        model        VARCHAR(50) NOT NULL DEFAULT '',
        createTime   DATETIME NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE INDEX name_index    ON "$DB_NAME_START"_1.log(username);
CREATE INDEX action_index  ON "$DB_NAME_START"_1.log(action);
CREATE INDEX channel_index ON "$DB_NAME_START"_1.log(channel);
CREATE INDEX time_index    ON "$DB_NAME_START"_1.log(createTime);
CREATE INDEX type_index    ON "$DB_NAME_START"_1.log(type);


DROP TABLE IF EXISTS "$DB_NAME_START"_1.questions;
CREATE TABLE "$DB_NAME_START"_1.questions (
        id             INT PRIMARY KEY AUTO_INCREMENT,
        question       VARCHAR(100) NOT NULL DEFAULT '', 
        createTime     DATETIME NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;


DROP TABLE IF EXISTS "$DB_NAME_START"_1.statistics;
CREATE TABLE "$DB_NAME_START"_1.statistics (
        id           INT PRIMARY KEY AUTO_INCREMENT,
        total        BIGINT NOT NULL DEFAULT 0,
        newer        INT    NOT NULL DEFAULT 0,
        actDay       INT    NOT NULL DEFAULT 0,
        actWeek      INT    NOT NULL DEFAULT 0,
        actMonth     INT    NOT NULL DEFAULT 0,
        channel      VARCHAR(64) NOT NULL DEFAULT '',
        idUser       INT    NOT NULL DEFAULT 0,
        mailUser     INT    NOT NULL DEFAULT 0,
phoneUser    INT    NOT NULL DEFAULT 0,
        type         TINYINT NOT NULL DEFAULT 0,
        account      TINYINT NOT NULL DEFAULT 0,
        createTime   DATETIME NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE INDEX time_index ON "$DB_NAME_START"_1.statistics(createTime);
CREATE INDEX type_index ON "$DB_NAME_START"_1.statistics(type);


DROP TABLE IF EXISTS "$DB_NAME_START"_1.admin;
CREATE TABLE "$DB_NAME_START"_1.admin (
        id             INT PRIMARY KEY AUTO_INCREMENT,
        username       VARCHAR(64) NOT NULL DEFAULT '', 
        password       VARCHAR(128) NOT NULL DEFAULT '', 
        createTime     DATETIME NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

DROP TABLE IF EXISTS "$DB_NAME_START"_1.version;
CREATE TABLE "$DB_NAME_START"_1.version (
        id                INT PRIMARY KEY AUTO_INCREMENT,
        strategy          VARCHAR(64) NOT NULL DEFAULT '', 
        versionName       VARCHAR(64) NOT NULL DEFAULT '', 
        file              VARCHAR(128) NOT NULL DEFAULT '',
        content           VARCHAR(256) NOT NULL DEFAULT '',
        startUpTime       DATE NOT NULL,
        endUpTime         DATE NOT NULL,
        versionKey        VARCHAR(32) NOT NULL DEFAULT '',
        updateTime        DATETIME NOT NULL,
        createTime        DATETIME NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE INDEX time_index ON "$DB_NAME_START"_1.version(createTime);
CREATE INDEX version_index ON "$DB_NAME_START"_1.version(versionName);

DROP TABLE IF EXISTS "$DB_NAME_START"_1.Tickets64;
CREATE TABLE "$DB_NAME_START"_1.Tickets64 (
  id         INT PRIMARY KEY auto_increment,
  table_seq  INT UNSIGNED NOT NULL,
  table_id   BIGINT(20) UNSIGNED NOT NULL,
  UNIQUE KEY table_seq (table_seq)
) ENGINE=MyISAM;
INSERT INTO account_2.Tickets64(table_seq, table_id) values(1, 2);
"
#执行命令
echo "${CREATE_TABLES_SQL}" | ${MYSQL_CON}

echo "执行完成..."

 

 

#! /bin/bash

PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/jdk/bin

while :
do

#NGINX_STATUS=`curl -s -k --head https://121.199.2.11 | awk '/HTTP/ {print $2}'`
NGINX_IS_STARTED=`ps aux | grep nginx | awk '/master/ { print "1" }'`

TOMCAT_STATUS=`curl -s --head http://localhost:8080 | awk '/HTTP/ {print $2}'`

TOMCAT_IS_STARTED=`ps aux | grep tomcat | awk '$NF == "start" {print "1"}'`
TOMCAT_PID=`ps aux | grep tomcat | awk '$NF == "start" {print $2}'`

# tomcat is shutdown
if [ "$TOMCAT_IS_STARTED" != "1" ]
then
        # start the tomcat
        sh /usr/local/tomcat/bin/startup.sh
        curl -H "token:token_app" -F "to=mail@com" -F "cc=mail@com" -F "subject=amazon-alarm" -F "content=server-54.210.61.11 tomcat is shutdown and restarting, please check log and ensure it runing"  http://101.69.181.82:8080/mail-service/webservice/mailService/sendMailByParam
fi

# tomcat is fault
if [ "$TOMCAT_IS_STARTED" = "1" ] && [ $TOMCAT_STATUS -ne 200 ]
then
        # kill tomcat
        kill -9 $TOMCAT_PID
        # restart tomcat
        sh /usr/local/tomcat/bin/startup.sh
        curl -H "token:token_app" -F "to=xiaolong.hou@tcl.com" -F "cc=wanming.zhang@tcl.com" -F "subject=amazon-alarm" -F "content=server-54.210.61.119 tomcat is fault and restarting, please check log and ensure it runing"  http://101.69.181.82:8080/mail-service/webservice/mailService/sendMailByParam
fi

# nginx is shutdown
if [ "$NGINX_IS_STARTED" != "1" ]
then
        # start nginx
        /usr/local/nginx/nginx
        curl -H "token:token_app" -F "to=mail@.com" -F "cc=mail@com" -F "subject=amazon-alarm" -F "content=server-54.210.61.11 nginx is shutdown and restarting, please check log and ensure it runing"  http://101.69.181.8:8080/mail-service/webservice/mailService/sendMailByParam
fi
sleep 30
done
exit 0

 

 

#! /bin/bash

PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/jdk/bin

# local to server2
while :
do
        rsync -vzurtopg --progress --delete /data/version/* root@10.0.0.38:/data/version/ 1>&2 2> /dev/null
sleep 20
done

 

 2.maven

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>

	<groupId>com.sosop.base</groupId>
	<artifactId>base-setting</artifactId>
	<version>1.0.0-SNAPSHOT</version>
	<packaging>pom</packaging>
	<name>base-setting</name>
	<url>http://maven.apache.org</url>

	<modules>
		<module>../ha-hit-redis</module>
		<module>../cache-redis-client</module>
	</modules>

	<properties>
		<jdk.version>1.7</jdk.version>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
		<junit.version>4.11</junit.version>
		<spring.version>4.0.5.RELEASE</spring.version>
		<log4j.version>1.2.16</log4j.version>
		<slf4j.version>1.7.6</slf4j.version>
		<hamcrest.version>1.3</hamcrest.version>
		<servlet.version>3.1.0</servlet.version>
		<jackson.version>1.9.13</jackson.version>
		<jedis.version>2.6.0</jedis.version>
		<beanUtils.version>1.9.2</beanUtils.version>
		<perf4j.version>0.9.16</perf4j.version>
		<mybatis.version>3.2.8</mybatis.version>
		<myBatis-spring.version>1.2.2</myBatis-spring.version>
		<dbcp.version>1.4</dbcp.version>
		<mysql.version>5.1.33</mysql.version>
		<jexl.version>1.1</jexl.version>
		<aspectj.version>1.8.2</aspectj.version>
		<cglib.version>3.1</cglib.version>
		<mybatis-generator.version>1.3.2</mybatis-generator.version>
		<hessian.version>4.0.38</hessian.version>
		<jstl.version>1.2</jstl.version>
		<common-io.version>2.2</common-io.version>
		<commons-lang.version>2.5</commons-lang.version>
		<jmock.version>2.6.0</jmock.version>
		<reflectasm.version>1.09</reflectasm.version>
		<jetty.version>8.1.16.v20140903</jetty.version>
		<commons-fileupload.version>1.3.1</commons-fileupload.version>
		<jdom.version>2.0.2</jdom.version>
		<thrift.version>0.9.1</thrift.version>
	</properties>

	<build>
		<finalName>base-setting</finalName>
		<pluginManagement>
			<plugins>
				<plugin>
					<groupId>org.apache.maven.plugins</groupId>
					<artifactId>maven-compiler-plugin</artifactId>
					<configuration>
						<source>${jdk.version}</source>
						<target>${jdk.version}</target>
					</configuration>
				</plugin>
				<plugin>
					<groupId>org.apache.maven.plugins</groupId>
					<artifactId>maven-resources-plugin</artifactId>
					<configuration>
						<encoding>${project.build.sourceEncoding}</encoding>
					</configuration>
				</plugin>
				<plugin>
					<groupId>org.mybatis.generator</groupId>
					<artifactId>mybatis-generator-maven-plugin</artifactId>
					<version>${mybatis-generator.version}</version>
					<configuration>
						<verbose>true</verbose>
						<overwrite>true</overwrite>
					</configuration>
				</plugin>
				<plugin>
					<groupId>org.mortbay.jetty</groupId>
					<artifactId>jetty-maven-plugin</artifactId>
					<version>${jetty.version}</version>
					<configuration>
						<scanIntervalSeconds>10</scanIntervalSeconds>
						<webApp>
							<contextPath>/</contextPath>
						</webApp>
					</configuration>
				</plugin>
			</plugins>
		</pluginManagement>
	</build>


	<dependencyManagement>
		<dependencies>
			<!-- junit -->
			<dependency>
				<groupId>junit</groupId>
				<artifactId>junit</artifactId>
				<version>${junit.version}</version>
				<scope>test</scope>
				<exclusions>
					<exclusion>
						<groupId>org.hamcrest</groupId>
						<artifactId>hamcrest-core</artifactId>
					</exclusion>
				</exclusions>
			</dependency>
			<dependency>
				<groupId>org.hamcrest</groupId>
				<artifactId>hamcrest-all</artifactId>
				<version>${hamcrest.version}</version>
				<scope>test</scope>
			</dependency>
			<dependency>
				<groupId>org.springframework</groupId>
				<artifactId>spring-test</artifactId>
				<version>${spring.version}</version>
				<scope>test</scope>
			</dependency>
			<dependency>
				<groupId>org.jmock</groupId>
				<artifactId>jmock</artifactId>
				<version>${jmock.version}</version>
				<scope>test</scope>
				<exclusions>
					<exclusion>
						<groupId>org.hamcrest</groupId>
						<artifactId>hamcrest-core</artifactId>
					</exclusion>
					<exclusion>
						<groupId>org.hamcrest</groupId>
						<artifactId>hamcrest-library</artifactId>
					</exclusion>
				</exclusions>
			</dependency>
			<!-- junit -->

			<!-- common-jexl -->
			<dependency>
				<groupId>commons-jexl</groupId>
				<artifactId>commons-jexl</artifactId>
				<version>${jexl.version}</version>
			</dependency>
			<!-- common-jexl -->

			<!-- aspectj -->
			<dependency>
				<groupId>org.aspectj</groupId>
				<artifactId>aspectjrt</artifactId>
				<version>${aspectj.version}</version>
			</dependency>
			<!-- aspectj -->

			<!-- aspectj-weaver -->
			<dependency>
				<groupId>org.aspectj</groupId>
				<artifactId>aspectjweaver</artifactId>
				<version>${aspectj.version}</version>
			</dependency>
			<!-- aspectj-weaver -->


			<!-- spring -->
			<dependency>
				<groupId>org.springframework</groupId>
				<artifactId>spring-context</artifactId>
				<version>${spring.version}</version>
			</dependency>
			<dependency>
				<groupId>org.springframework</groupId>
				<artifactId>spring-context-support</artifactId>
				<version>${spring.version}</version>
			</dependency>
			<dependency>
				<groupId>org.springframework</groupId>
				<artifactId>spring-core</artifactId>
				<version>${spring.version}</version>
			</dependency>
			<dependency>
				<groupId>org.springframework</groupId>
				<artifactId>spring-beans</artifactId>
				<version>${spring.version}</version>
			</dependency>
			<dependency>
				<groupId>org.springframework</groupId>
				<artifactId>spring-web</artifactId>
				<version>${spring.version}</version>
			</dependency>
			<dependency>
				<groupId>org.springframework</groupId>
				<artifactId>spring-webmvc</artifactId>
				<version>${spring.version}</version>
			</dependency>
			<dependency>
				<groupId>org.springframework</groupId>
				<artifactId>spring-aop</artifactId>
				<version>${spring.version}</version>
			</dependency>
			<dependency>
				<groupId>org.springframework</groupId>
				<artifactId>spring-jdbc</artifactId>
				<version>${spring.version}</version>
			</dependency>
			<dependency>
				<groupId>org.springframework</groupId>
				<artifactId>spring-tx</artifactId>
				<version>${spring.version}</version>
			</dependency>
			<dependency>
				<groupId>org.springframework</groupId>
				<artifactId>spring-orm</artifactId>
				<version>${spring.version}</version>
			</dependency>
			<dependency>
				<groupId>org.springframework</groupId>
				<artifactId>spring-expression</artifactId>
				<version>${spring.version}</version>
			</dependency>
			<!-- spring -->

			<!-- myBatis -->
			<dependency>
				<groupId>org.mybatis</groupId>
				<artifactId>mybatis</artifactId>
				<version>${mybatis.version}</version>
			</dependency>
			<!-- myBatis -->

			<!-- myBatis-spring -->
			<dependency>
				<groupId>org.mybatis</groupId>
				<artifactId>mybatis-spring</artifactId>
				<version>${myBatis-spring.version}</version>
			</dependency>
			<!-- myBatis-spring -->

			<!-- log4j -->
			<dependency>
				<groupId>log4j</groupId>
				<artifactId>log4j</artifactId>
				<version>${log4j.version}</version>
			</dependency>
			<dependency>
				<groupId>org.slf4j</groupId>
				<artifactId>slf4j-api</artifactId>
				<version>${slf4j.version}</version>
			</dependency>
			<dependency>
				<groupId>org.slf4j</groupId>
				<artifactId>slf4j-log4j12</artifactId>
				<version>${slf4j.version}</version>
			</dependency>
			<!-- log4j -->

			<!-- jackson -->
			<dependency>
				<groupId>org.codehaus.jackson</groupId>
				<artifactId>jackson-core-asl</artifactId>
				<version>${jackson.version}</version>
			</dependency>
			<dependency>
				<groupId>org.codehaus.jackson</groupId>
				<artifactId>jackson-mapper-asl</artifactId>
				<version>${jackson.version}</version>
			</dependency>
			<dependency>
				<groupId>org.codehaus.jackson</groupId>
				<artifactId>jackson-jaxrs</artifactId>
				<version>${jackson.version}</version>
			</dependency>
			<dependency>
				<groupId>org.codehaus.jackson</groupId>
				<artifactId>jackson-xc</artifactId>
				<version>${jackson.version}</version>
			</dependency>
			<!-- jackson -->

			<!-- jedis -->
			<dependency>
				<groupId>redis.clients</groupId>
				<artifactId>jedis</artifactId>
				<version>${jedis.version}</version>
			</dependency>
			<!-- jedis -->

			<!-- bean utlis -->
			<dependency>
				<groupId>commons-beanutils</groupId>
				<artifactId>commons-beanutils</artifactId>
				<version>${beanUtils.version}</version>
			</dependency>
			<!-- bean utils -->

			<!-- servlet api -->
			<dependency>
				<groupId>javax.servlet</groupId>
				<artifactId>javax.servlet-api</artifactId>
				<version>${servlet.version}</version>
				<scope>provided</scope>
			</dependency>
			<!-- servlet api -->

			<!-- perf4j -->
			<dependency>
				<groupId>org.perf4j</groupId>
				<artifactId>perf4j</artifactId>
				<version>${perf4j.version}</version>
			</dependency>
			<!-- perf4j -->

			<!-- dbcp -->
			<dependency>
				<groupId>commons-dbcp</groupId>
				<artifactId>commons-dbcp</artifactId>
				<version>${dbcp.version}</version>
			</dependency>
			<!-- dbcp -->

			<!-- jdbc mysql -->
			<dependency>
				<groupId>mysql</groupId>
				<artifactId>mysql-connector-java</artifactId>
				<version>${mysql.version}</version>
			</dependency>
			<!-- jdbc mysql -->

			<!-- cglib -->
			<dependency>
				<groupId>cglib</groupId>
				<artifactId>cglib</artifactId>
				<version>${cglib.version}</version>
			</dependency>
			<!-- cglib -->

			<!-- mybatis-generator -->
			<dependency>
				<groupId>org.mybatis.generator</groupId>
				<artifactId>mybatis-generator-core</artifactId>
				<version>${mybatis-generator.version}</version>
			</dependency>
			<!-- mybatis-generator -->
			<!-- hessian -->
			<dependency>
				<groupId>com.caucho</groupId>
				<artifactId>hessian</artifactId>
				<version>${hessian.version}</version>
			</dependency>
			<!-- hessian -->
			<!-- jstl -->
			<dependency>
				<groupId>jstl</groupId>
				<artifactId>jstl</artifactId>
				<version>${jstl.version}</version>
			</dependency>
			<!-- jstl -->

			<!--common io -->
			<dependency>
				<groupId>commons-io</groupId>
				<artifactId>commons-io</artifactId>
				<version>${common-io.version}</version>
			</dependency>
			<!--common io -->
			<!--common lang -->
			<dependency>
				<groupId>commons-lang</groupId>
				<artifactId>commons-lang</artifactId>
				<version>${commons-lang.version}</version>
			</dependency>
			<!--common lang -->
			<!-- reflectASM -->
			<dependency>
				<groupId>com.esotericsoftware.reflectasm</groupId>
				<artifactId>reflectasm</artifactId>
				<version>${reflectasm.version}</version>
			</dependency>
			<!-- reflectASM -->
			<!--common upload -->
			<dependency>
				<groupId>commons-fileupload</groupId>
				<artifactId>commons-fileupload</artifactId>
				<version>${commons-fileupload.version}</version>
			</dependency>
			<!--common upload -->
			<!-- jdom -->
			<dependency>
				<groupId>org.jdom</groupId>
				<artifactId>jdom</artifactId>
				<version>${jdom.version}</version>
			</dependency>
			<!-- jdom -->
			<!-- thrift -->
			<dependency>
				<groupId>org.apache.thrift</groupId>
				<artifactId>libthrift</artifactId>
				<version>${thrift.version}</version>
			</dependency>
			<!-- thrift -->
		</dependencies>
	</dependencyManagement>

</project>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>

	<parent>
		<groupId>com.sosop.base</groupId>
		<artifactId>base-setting</artifactId>
		<version>1.0.0-SNAPSHOT</version>
		<relativePath>../base/pom.xml</relativePath>
	</parent>

	<artifactId>cache-redis</artifactId>
	<packaging>jar</packaging>
	<name>cache-redis</name>

	<properties>
        <maven.test.skip>true</maven.test.skip>
    </properties>

	<build>
		<finalName>cache-redis</finalName>
		<pluginManagement>
			<plugins>
				<plugin>
					<groupId>org.apache.maven.plugins</groupId>
					<artifactId>maven-compiler-plugin</artifactId>
				</plugin>
				<plugin>
					<groupId>org.apache.maven.plugins</groupId>
					<artifactId>maven-resources-plugin</artifactId>
				</plugin>
				<plugin>
					<artifactId>maven-assembly-plugin</artifactId>
					<configuration>
						<appendAssemblyId>false</appendAssemblyId>
						<descriptorRefs>
							<descriptorRef>jar-with-dependencies</descriptorRef>
						</descriptorRefs>
						<archive>
							<manifest>
								<mainClass>com.sosop.cache.redis.thrift.Server</mainClass>
							</manifest>
						</archive>
					</configuration>
					<executions>
						<execution>
							<id>make-assembly</id>
							<phase>package</phase>
							<goals>
								<goal>assembly</goal>
							</goals>
						</execution>
					</executions>
				</plugin>
			</plugins>
		</pluginManagement>
	</build>

	<dependencies>
		<!-- jedis -->
		<dependency>
			<groupId>redis.clients</groupId>
			<artifactId>jedis</artifactId>
		</dependency>
		<!-- jedis -->
		<!-- log4j -->
		<dependency>
			<groupId>log4j</groupId>
			<artifactId>log4j</artifactId>
		</dependency>
		<!-- log4j -->
		<!-- bean utlis -->
		<dependency>
			<groupId>commons-beanutils</groupId>
			<artifactId>commons-beanutils</artifactId>
		</dependency>
		<!-- bean utils -->
		<!-- junit -->
		<dependency>
			<groupId>junit</groupId>
			<artifactId>junit</artifactId>
			<scope>test</scope>
			<exclusions>
				<exclusion>
					<groupId>org.hamcrest</groupId>
					<artifactId>hamcrest-core</artifactId>
				</exclusion>
			</exclusions>
		</dependency>
		<dependency>
			<groupId>org.hamcrest</groupId>
			<artifactId>hamcrest-all</artifactId>
			<scope>test</scope>
		</dependency>
		<!-- junit -->
		<!-- reflectASM -->
		<dependency>
			<groupId>com.esotericsoftware.reflectasm</groupId>
			<artifactId>reflectasm</artifactId>
		</dependency>
		<!-- reflectASM -->
		<!-- jdom -->
		<dependency>
			<groupId>org.jdom</groupId>
			<artifactId>jdom</artifactId>
		</dependency>
		<!-- jdom -->
		<!-- thrift -->
		<dependency>
			<groupId>org.apache.thrift</groupId>
			<artifactId>libthrift</artifactId>
		</dependency>
		<!-- thrift -->
		<!-- log -->
		<dependency>
			<groupId>org.slf4j</groupId>
			<artifactId>slf4j-api</artifactId>
		</dependency>
		<dependency>
			<groupId>org.slf4j</groupId>
			<artifactId>slf4j-log4j12</artifactId>
		</dependency>
		<!-- log -->
	</dependencies>
</project>

  

maven jetty:run -Djetty.port=xxxx

 maven assembly:assembly

 

3.java

package com.tcl.aota.admin.util;

import com.tcl.aota.persistent.model.Admin;
import org.apache.commons.lang.StringUtils;

import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 * @author kelong
 * @date 11/7/14
 */
public class SessionFilter implements Filter {
    private static String loginPage = "/admin/login";
    private static Set<String> ignoreUrls = new HashSet<String>();
    private static List<String> ignoreStaticUrls=new ArrayList<String>();
    private static String CONTEXTPATH = null;

    static {
        ignoreUrls.add("/admin/login");
        ignoreUrls.add("/admin/loginSys");
        ignoreStaticUrls.add("/");
    }

    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
        String configIgnoreUrl = filterConfig.getInitParameter("config");
        if (!StringUtils.isEmpty(configIgnoreUrl)) {
            String[] urls = configIgnoreUrl.split(",");
            for (String url : urls) {
                ignoreUrls.add(url);
            }
        }
        CONTEXTPATH = filterConfig.getServletContext().getContextPath();
    }

    @Override
    public void doFilter(ServletRequest request, ServletResponse response,
                         FilterChain filterChain) throws IOException, ServletException {
        HttpServletRequest servletRequest = (HttpServletRequest) request;
        HttpServletResponse servletResponse = (HttpServletResponse) response;
        String servletPath = servletRequest.getServletPath();
        if (ignoreUrls.contains(servletPath)) {
            filterChain.doFilter(request, response);
            return;
        }

        if (servletPath.matches(".+\\..+")) {
            filterChain.doFilter(request, response);
            return;
        }
        Admin admin = RequestUtil.getSessionUser(servletRequest);
        if (admin == null) {
            servletResponse.sendRedirect(CONTEXTPATH + loginPage);
        } else {
            filterChain.doFilter(request, response);
        }

    }

    @Override
    public void destroy() {

    }
}

 

<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:mvc="http://www.springframework.org/schema/mvc" xmlns:p="http://www.springframework.org/schema/p"
	xsi:schemaLocation="http://www.springframework.org/schema/beans
	http://www.springframework.org/schema/beans/spring-beans.xsd
	http://www.springframework.org/schema/context
	http://www.springframework.org/schema/context/spring-context.xsd
	http://www.springframework.org/schema/mvc
	http://www.springframework.org/schema/mvc/spring-mvc.xsd">

	<bean id="viewResolver"
		class="org.springframework.web.servlet.view.InternalResourceViewResolver"
		p:viewClass="org.springframework.web.servlet.view.JstlView" 
		p:prefix="/WEB-INF/jsp/"
		p:suffix=".jsp" />
    <mvc:resources mapping="/**" location="/" order="1"/>
	<mvc:resources location="/bower_components/" mapping="/bower_components/**"/>
	<mvc:resources location="/scripts/" mapping="/scripts/**"/>
	<mvc:resources location="/images/" mapping="/images/**"/>
	<mvc:resources location="/styles/" mapping="/styles/**"/>
	<mvc:resources location="/views/" mapping="/views/**"/>
	<mvc:resources location="/test/" mapping="/test/**"/>
    <!--<mvc:annotation-driven />-->


    <bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping">
      <property name="order" value="0"/>
      <property name="useDefaultSuffixPattern" value="false"/>
    </bean>

    <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"/>
	
	<!-- <mvc:interceptors >    
      <bean class="com.tcl.aota.admin.inteceptor.SessionInteceptor"/>
    </mvc:interceptors>   -->

    <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
        <property name="maxUploadSize" value="104857600"/>
    </bean>
</beans>

 

相关标签: tools