Skip to content

Commit 1e9b9cc

Browse files
committed
获取依赖:sh start.sh install
1 parent 5df0d07 commit 1e9b9cc

File tree

6 files changed

+45
-21
lines changed

6 files changed

+45
-21
lines changed

README.en.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ Software architecture description
99
#### Installation
1010

1111
1. redis-server
12-
2. mvn compile
13-
3. mvn exec:exec
12+
2. sh start.sh install
13+
3. mvn compile
14+
4. mvn exec:exec
1415

1516
profile "debug" is activated by default.
1617

README.md

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,20 @@
44
使用light-4j构建的微服务接口应用
55

66
#### 本地测试
7-
1. 项目构建:sh start.sh package
8-
2. 启动缓存:redis-server
9-
3. 运行项目:start.bat
10-
4. 测试访问:[logs](http://localhost:8080/ws/logs.html)[datetime](http://localhost:8080/service/datetime.json)
7+
1. 获取依赖:sh start.sh install,项目构建:sh start.sh package
8+
2. 启动缓存:redis-server,运行项目:start.bat
9+
3. 测试访问:[chat](http://localhost:8080/ws/chat.html)[datetime](http://localhost:8080/service/datetime.json)
1110

1211
#### 线上部署
13-
1. 项目打包:sh start.sh deploy
14-
2. 提取脚本:jar xvf light4j.jar start.sh
15-
3. 运行服务:sh start.sh start
12+
1. 获取依赖:sh start.sh install,项目打包:sh start.sh deploy
13+
2. 提取脚本:jar xvf light4j.jar start.sh,修改配置:vi start.sh
14+
3. 启动缓存:redis-server,运行服务:sh start.sh start
1615

1716
#### 配置说明
1817
vi start.sh
1918

20-
1. -Dredis.configDb,配置redis地址
21-
2. -Dlight4j.directory,可以从light4j.yml里面的网址下载文件
19+
1. -Dredis.configDb、-Dredis.cacheDbs,配置redis地址
20+
2. -Dlight4j.directory,相关资源可在[library](http://t.xlongwei.com/softwares/library/)获取
2221
3. -Dlogserver,在/etc/hosts配置logserver地址
2322
4. contextName=light4j,修改应用的日志上下文
2423
5. -Djava.compiler=none,禁用JIT可节约内存,默认启用JIT可提高性能

pom.xml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -259,11 +259,17 @@
259259
<artifactId>apijson-orm</artifactId>
260260
<version>${version.apijson}</version>
261261
</dependency>
262+
<!-- https://jitpack.io -->
262263
<dependency>
263264
<groupId>com.github.APIJSON</groupId>
264265
<artifactId>apijson-framework</artifactId>
265266
<version>${version.apijson}</version>
266267
</dependency>
268+
<dependency>
269+
<groupId>javax.servlet</groupId>
270+
<artifactId>javax.servlet-api</artifactId>
271+
<version>4.0.1</version>
272+
</dependency>
267273
<dependency>
268274
<groupId>com.googlecode.log4jdbc</groupId>
269275
<artifactId>log4jdbc</artifactId>
@@ -517,11 +523,4 @@
517523

518524
</build>
519525

520-
521-
<repositories>
522-
<repository>
523-
<id>jitpack.io</id>
524-
<url>https://jitpack.io</url>
525-
</repository>
526-
</repositories>
527526
</project>

src/main/java/com/xlongwei/light4j/handler/service/WeixinHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public void notify(HttpServerExchange exchange) throws Exception {
7777
.putJSON("notice")
7878
.put("value", text)
7979
.top().json();
80-
JSONObject resp = WeixinUtil.templateSend(WeixinUtil.accessToken(WeixinUtil.appidTest, WeixinUtil.appsecretTest), send);
80+
JSONObject resp = WeixinUtil.templateSend(WeixinUtil.accessToken(WeixinUtil.appidTest, StringUtil.firstNotBlank(RedisConfig.get(WeixinUtil.cache, "appsecret."+WeixinUtil.appidTest), "d4624c36b6795d1d99dcf0547af5443d")), send);
8181
HandlerUtil.setResp(exchange, StringUtil.params("text", StringUtil.firstNotBlank(JsonUtil.get(resp, "errmsg"), "失败")));
8282
}
8383

src/main/java/com/xlongwei/light4j/util/WeixinUtil.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@
3434
@Slf4j
3535
@SuppressWarnings({"rawtypes","unchecked"})
3636
public class WeixinUtil {
37-
public static final String service = "https://api.weixin.qq.com/cgi-bin/", appid = "wx78b808148023e9fa";
38-
public static final String appidTest = "wx5bb3e90365f54b7a", touserTest = "gh_f6216a9ae70b", appsecretTest = "d4624c36b6795d1d99dcf0547af5443d";
37+
public static final String service = "https://api.weixin.qq.com/cgi-bin/", appid = StringUtil.firstNotBlank(System.getProperty("weixin.appid"), "wx78b808148023e9fa");
38+
public static final String appidTest = StringUtil.firstNotBlank(System.getProperty("weixin.appidTest"), "wx5bb3e90365f54b7a"), touserTest = StringUtil.firstNotBlank(System.getProperty("weixin.touserTest"), "gh_f6216a9ae70b");
3939
public static final String cache = "weixin", accessTokenKey = "access_token", jsapiTicketKey = "jsapi_ticket";
4040
private static final Map<Class<?>,Field[]> fieldsCache = new HashMap<>(32);
4141
private static final Map<String, Class<? extends AbstractMessage>> classCache = new HashMap<>(16);

start.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Survivor=2 Old=64 NewSize=$[Survivor*10] Xmx=$[NewSize+Old] #NewSize=Survivor*(1
99
JVM_OPS="-Djava.compiler=none -Xmx${Xmx}m -Xms${Xmx}m -XX:NewSize=${NewSize}m -XX:MaxNewSize=${NewSize}m -XX:SurvivorRatio=8 -Xss228k"
1010
JVM_OPS="$JVM_OPS -Dlogserver -DcontextName=light4j"
1111
#JVM_OPS="$JVM_OPS -Dapijson.enabled=true -Dapijson.debug=false -Dapijson.test=false"
12+
#JVM_OPS="$JVM_OPS -Dweixin.appid=wx78b808148023e9fa -Dweixin.appidTest=wx5bb3e90365f54b7a -Dweixin.touserTest=gh_f6216a9ae70b"
1213
#ENV_OPS="PATH=/usr/java/jdk1.8.0_161/bin:$PATH"
1314
JVM_OPS="$JVM_OPS -Dlight4j.directory=/soft/softwares/library/"
1415
#JVM_OPS="$JVM_OPS -Dredis.configDb=xlongwei:6379:1"
@@ -38,6 +39,7 @@ usage(){
3839
echo " deploy package fat-jar $jarfile"
3940
echo " redeploy package fat-jar $jarfile and restart"
4041
echo " keystore prepare keystore、crt、trustore"
42+
echo " install download some jars and install to local repository"
4143
}
4244

4345
status(){
@@ -108,6 +110,28 @@ keystore(){
108110
keytool -import -file $cert/xlongwei.pem -alias server -keystore $dir/client.truststore -storepass password
109111
}
110112

113+
install(){
114+
[ ! -e target ] && mkdir target
115+
repos=http://nexus.xlongwei.com/repos/
116+
install_file "$repos" "de.rrze" "jpwgen" "1.2.0"
117+
install_file "$repos" "com.qq.weixin.mp" "aes" "1.6"
118+
install_file "$repos" "com.lowagie" "itext" "2.0.8.1"
119+
install_file "$repos" "com.lowagie" "itext-asian" "2.0.8.1"
120+
repos=https://jitpack.io/
121+
install_file "$repos" "com.github.APIJSON" "apijson-framework" "4.2.3"
122+
install_file "$repos" "com.github.APIJSON" "apijson-orm" "4.2.3"
123+
}
124+
install_file(){
125+
groupId="$2" && artifactId="$3" && version="$4" && url="$1${groupId//.//}/${artifactId}/${version}/${artifactId}-${version}.jar"
126+
echo "install $url to $groupId:$artifactId:jar:$version"
127+
out="target/${artifactId}-${version}.jar"
128+
if [ ! -e $out ]; then
129+
echo "download jar and install-file"
130+
curl -s $url -o $out
131+
mvn install:install-file -DgroupId=$groupId -DartifactId=$artifactId -Dversion=$version -Dpackaging=jar -Dfile=$out
132+
fi
133+
}
134+
111135
if [ $# -eq 0 ]; then
112136
usage
113137
else
@@ -125,6 +149,7 @@ else
125149
deploy) deploy ;;
126150
redeploy) stop && deploy && start ;;
127151
keystore) keystore $@;;
152+
install) install ;;
128153
*) usage ;;
129154
esac
130155
fi

0 commit comments

Comments
 (0)