In the previous article, we introduced build dubbo distributed platform maven build ant parent project. The framework uses maven to build. According to our plan, we need to build all subprojects. Today, we focus on the construction process of ant config configuration file project.
Introduction: The purpose of independent ant config project is to manage all configuration files in a unified project, including: spring related file configuration, mybatis related file configuration, data source related file configuration, basic environment file configuration (SMS, message, oss storage, third-party login, email, etc.), redis or ehcache cache related configuration, log4j log file related configuration Set and unify error exception configuration, spring Shiro permission related configuration, spring and redis cache integration related configuration, etc.
1. Create ant config subproject and inherit ant parent project. I omitted the creation process of eclipse. The pom.xml file is configured as follows:
<span style="font-size: 16px;"><?xml version="1.0"?> <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>com.sml.sz</groupId> <artifactId>ant-project</artifactId> <version>1.0.0</version> </parent> <artifactId>ant-config</artifactId> <name>ant-config</name> <url>http://maven.apache.org</url> <packaging>jar</packaging> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> <build> <!-- maven Package name after packaging --> <finalName>ant-config</finalName> <resources> <!-- Appoint src/main/resources All files and folders below are resource files --> <resource> <directory>src/main/resources</directory> <targetPath>${project.build.directory}/classes</targetPath> <includes> <include>**/*</include> </includes> <filtering>true</filtering> </resource> <!-- according to env Deploy the environment value and copy the configuration file of the corresponding environment to classes Catalog --> <resource> <directory>deployEnv/${env}</directory> <targetPath>${project.build.directory}/classes</targetPath> <filtering>true</filtering> </resource> </resources> </build> </project> </span>
2. Create log4j.properties file and configure it as follows:
<span style="font-size: 16px;"># Output pattern : date [thread] priority category - message FATAL 0 ERROR 3 WARN 4 INFO 6 DEBUG 7 log4j.rootLogger=WARN, Console, RollingFile #Console log4j.appender.Console=org.apache.log4j.ConsoleAppender log4j.appender.Console.layout=org.apache.log4j.PatternLayout log4j.appender.Console.layout.ConversionPattern=%d %-5p [%c{5}] - %m%n #RollingFile log4j.appender.RollingFile=org.apache.log4j.DailyRollingFileAppender log4j.appender.RollingFile.File=/logs/ant/ant.log log4j.appender.RollingFile.layout=org.apache.log4j.PatternLayout log4j.appender.RollingFile.layout.ConversionPattern=%d [%t] %-5p [%c] - %m%n #log4j.logger.java.sql=DEBUG #Project defalult level log4j.logger.com.sml.sz=DEBUG log4j.logger.com.sml.sz.common.security.shiro=WARN log4j.logger.com.sml.sz.JedisUtils=WARN</span>
3. Create the ant.properties file, as follows:
<span style="font-size: 16px;">#--------------Database sttings-------------- #mysql database setting jdbc.type=mysql jdbc.driver=com.mysql.jdbc.Driver jdbc.url=jdbc:mysql://127.0.0.1:3306/ant-dubbo?useUnicode=true&characterEncoding=utf-8 jdbc.username=root jdbc.password=root #pool settings jdbc.pool.init=10 jdbc.pool.minIdle=30 jdbc.pool.maxActive=60 #--------------redis settings-------------- redis.keyPrefix=ant redis.host=127.0.0.1 redis.port=6379 #-------------- System settings -------------- #\u4ea7\u54c1\u4fe1\u606f\u8bbe\u7f6e logoName=ant productName=ant \u5206\u5E03\u5F0F\u4F01\u4E1A\u67B6\u6784 copyrightYear=2017 version=V1.0.0 #\u662f\u5426\u5141\u8bb8\u591a\u8d26\u53f7\u540c\u65f6\u767b\u5f55 user.multiAccountLogin=true #\u5206\u9875\u914d\u7f6e page.pageSize=10 #-------------- Framework settings -------------- #\u4f1a\u8bdd\u8d85\u65f6\uff0c \u5355\u4f4d\uff1a\u6beb\u79d2\uff0c 20m=1200000ms, 30m=1800000ms, 60m=3600000ms session.sessionTimeout=1800000 #\u4f1a\u8bdd\u6e05\u7406\u95f4\u9694\u65f6\u95f4\uff0c \u5355\u4f4d\uff1a\u6beb\u79d2\uff0c2m=120000ms\u3002 session.sessionTimeoutClean=120000 #\u89c6\u56fe\u6587\u4ef6\u5b58\u653e\u8def\u5f84 web.view.prefix=/WEB-INF/views/ web.view.suffix=.jsp web.maxUploadSize=10485760 #\u9759\u6001\u6587\u4ef6\u540e\u7f00 web.staticFile=.css,.js,.png,.jpg,.gif,.jpeg,.bmp,.ico,.swf,.psd,.htc,.htm,.html,.crx,.xpi,.exe,.ipa,.apk #--------------Email SMTP -------------- mail.host=smtp.163.com mail.port=25 mail.username=test@163.com mail.password=test mail.smtp.auth=true mail.smtp.timeout=30000 mail.default.from=test@163.com #-------------- JMS -------------- mq.brokerURL=failover\:(tcp\://127.0.0.1\:61616)?randomize\=false&initialReconnectDelay\=1000&maxReconnectDelay\=30000 mq.userName=ant mq.password=ant mq.pool.maxConnections=20 #queueName queueName.task=task_queue_1 </span>
Some distributed solutions. If you want to know about them, you can talk to our team
More detailed source references