`

工具使用

阅读更多

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>

 

分享到:
评论

相关推荐

    Pyang工具使用说明

    Pyang 工具使用说明 Pyang 工具是一款功能强大的工具,用于验证 YANG 模型文件的正确性,并将 YANG 模型转换成 UML 图模型或 tree 表现形式。在本文中,我们将详细介绍 Pyang 工具的安装、使用方法,以及如何使用 ...

    Atheros art 工具使用指南

    标题中的"Atheros art 工具使用指南"是指针对Atheros 93系列无线芯片的功率调优工具,主要用于提升无线设备的发射功率精度和接收灵敏度。这种工具在无线网络部署中尤其重要,因为它能确保信号覆盖范围的有效性和稳定...

    晶晨客制化工具使用说明.docx

    晶晨客制化工具使用说明 晶晨客制化工具使用说明是Amlogic公司针对晶晨S905rom固件的解包打包定制工具的使用手册。该工具包提供了详细的使用指南,指导用户如何安装和使用该工具,以满足不同用户的需求。 一、简介...

    瑞芯微Image打包工具使用说明

    该工具用于将各项目中使用的旧Image固件重新打包成供统一工具使用的新格式固件.目前支持RK28|RK281X|RKCROWN|RKNANO|RKCAYMAN|RK29|RK30|RK30B|RK31 |RK32|RK292X|RKPANDA|RKSMART

    内网渗透思路整理与工具使用

    内网渗透思路整理与工具使用内网渗透思路整理与工具使用内网渗透思路整理与工具使用内网渗透思路整理与工具使用内网渗透思路整理与工具使用

    高通QACT工具使用和EQ调试说明.docx

    高通QACT工具使用和EQ调试说明 一、QACT工具安装和配置 QACT工具是高通公司提供的一款强大的音频调试工具,用于配置和调试EQ参数。要使用QACT工具,首先需要安装V7.2.30版本的QACT工具,以及对应的TRB/USB驱动。 ...

    超级弱口令检查工具使用手册.docx

    暴力破解使用文档

    linux git工具使用

    linux git工具使用,很好git说明文档,命令操作很详细

    visio 工具使用方法

    Visio 工具使用方法,产品经理基础工具的使用,绘制流程图

    ps填充工具使用教程PPT教案.pptx

    Photoshop填充工具使用教程 Photoshop 是一款功能强大的图像编辑软件,填充工具是 Photoshop 的一个重要组件。本教程将指导您如何使用 Photoshop 的填充工具来编辑图像。 一、油漆桶工具 油漆桶工具是 Photoshop ...

    Android的ADB工具使用

    Android的ADB工具使用,有需要的朋友可以下载一下。

    CSV 快速拆分工具

    链接中的文章("CSV拆分工具使用方法及介绍")可能详细介绍了如何使用特定的CSV拆分工具,包括安装、启动、设置拆分参数、执行拆分操作以及保存结果等步骤。在实际应用中,根据具体情况选择合适的工具和方法至关重要...

    SAMBA工具使用指南

    SAMBA工具使用指南:UNIX与WINDOWS NT网络互连.

    IPOP工具及使用手册

    此外,调试工具的使用,如日志查看、命令行交互、性能图表分析等也会有详细的操作演示。这些功能对于网络维护人员来说至关重要,它们可以提供详细的设备信息,帮助用户深入理解网络状况。 性能监控是IPOP的另一大...

    版本控制与CVS工具使用说明.rar

    版本控制与cvs工具使用说明的ppt CVS简介 客户端工具--TortoiseCVS C/S架构 CVS仓库目录建立在服务器端,客户端的工作目录与之相对应,所有的CVS操作均在此工作目录中进行。 CVS客户端工具: Windows系统:...

    Depends工具

    depends工具使用方法: 1. 双击depends.exe ,运行该程序。 2. 将可执行文件拖到该窗口中。稍等片刻,出现depends 分析结果。 3. 左侧的树控件,显示了该exe 包含哪些module(dll),下面的列表是可能用到的dll 总表...

    Android开发 logcat工具使用

    Android开发中的logcat工具使用

    NaviCat工具使用.docx

    NaviCat工具使用.docx

Global site tag (gtag.js) - Google Analytics