Compare commits
19 Commits
v2.1
...
v2.1-local
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b79710a1fc | ||
|
|
af50397afb | ||
|
|
888b0e670f | ||
|
|
6067550bd2 | ||
|
|
e0d5d784f8 | ||
|
|
5ae844ea33 | ||
|
|
6eaa123087 | ||
|
|
f8c2ea8206 | ||
|
|
cf10cec717 | ||
|
|
7513fac8d8 | ||
|
|
f46c78b9f1 | ||
|
|
659c8e6f3b | ||
|
|
3d6530f148 | ||
|
|
0c00085e9f | ||
|
|
474b16c662 | ||
|
|
3a18a6b7a6 | ||
|
|
9cb5e77bb5 | ||
|
|
392c50ceb9 | ||
|
|
38152b7786 |
33
.gitignore
vendored
33
.gitignore
vendored
@@ -1,33 +0,0 @@
|
|||||||
HELP.md
|
|
||||||
target/
|
|
||||||
!.mvn/wrapper/maven-wrapper.jar
|
|
||||||
!**/src/main/**/target/
|
|
||||||
!**/src/test/**/target/
|
|
||||||
|
|
||||||
### STS ###
|
|
||||||
.apt_generated
|
|
||||||
.classpath
|
|
||||||
.factorypath
|
|
||||||
.project
|
|
||||||
.settings
|
|
||||||
.springBeans
|
|
||||||
.sts4-cache
|
|
||||||
|
|
||||||
### IntelliJ IDEA ###
|
|
||||||
.idea
|
|
||||||
*.iws
|
|
||||||
*.iml
|
|
||||||
*.ipr
|
|
||||||
|
|
||||||
### NetBeans ###
|
|
||||||
/nbproject/private/
|
|
||||||
/nbbuild/
|
|
||||||
/dist/
|
|
||||||
/nbdist/
|
|
||||||
/.nb-gradle/
|
|
||||||
build/
|
|
||||||
!**/src/main/**/build/
|
|
||||||
!**/src/test/**/build/
|
|
||||||
|
|
||||||
### VS Code ###
|
|
||||||
.vscode/
|
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
FROM ubuntu:latest
|
FROM ubuntu:jammy-20231004
|
||||||
MAINTAINER bamanker
|
MAINTAINER bamanker
|
||||||
ARG NATIVE_FILE
|
ARG NATIVE_FILE
|
||||||
COPY target/${NATIVE_FILE} /home/dailylove/app
|
ENV NATIVE_FILE=${NATIVE_FILE}
|
||||||
|
COPY target/${NATIVE_FILE} /home/${NATIVE_FILE}/app
|
||||||
EXPOSE 13145
|
EXPOSE 13145
|
||||||
ENTRYPOINT ["/home/dailylove/app"]
|
WORKDIR /home/${NATIVE_FILE}/out
|
||||||
|
ENTRYPOINT /home/${NATIVE_FILE}/app -XX:StartFlightRecording='filename=recording.jfr,dumponexit=true,duration=10s'
|
||||||
32
pom.xml
32
pom.xml
@@ -10,7 +10,7 @@
|
|||||||
</parent>
|
</parent>
|
||||||
<groupId>com.bamanker</groupId>
|
<groupId>com.bamanker</groupId>
|
||||||
<artifactId>dailylove</artifactId>
|
<artifactId>dailylove</artifactId>
|
||||||
<version>v2.0</version>
|
<version>v2.1-local</version>
|
||||||
<name>dailyLove</name>
|
<name>dailyLove</name>
|
||||||
<description>dailylove</description>
|
<description>dailylove</description>
|
||||||
<properties>
|
<properties>
|
||||||
@@ -68,6 +68,35 @@
|
|||||||
<groupId>org.graalvm.buildtools</groupId>
|
<groupId>org.graalvm.buildtools</groupId>
|
||||||
<artifactId>native-maven-plugin</artifactId>
|
<artifactId>native-maven-plugin</artifactId>
|
||||||
<version>0.9.27</version>
|
<version>0.9.27</version>
|
||||||
|
<!--为本机映像程序添加配置,生成的配置文件位于
|
||||||
|
META-INF/native-image/groupID/artifactID/native-image.properties
|
||||||
|
也可以手动配置-->
|
||||||
|
<configuration>
|
||||||
|
<buildArgs>
|
||||||
|
<!--开启dashboard-->
|
||||||
|
<!-- <arg>-H:DashboardDump=dailylove -H:+DashboardAll</arg>-->
|
||||||
|
<arg->-H:+ReportExceptionStackTraces</arg->
|
||||||
|
<!--开启JFR-->
|
||||||
|
<arg>--enable-monitoring=jfr</arg>
|
||||||
|
<arg>--gc=G1</arg>
|
||||||
|
<!-- <arg>--pgo</arg>-->
|
||||||
|
<arg>-Ob</arg>
|
||||||
|
<!-- <arg>-march=native</arg>-->
|
||||||
|
<arg>-H:+BuildReport</arg>
|
||||||
|
</buildArgs>
|
||||||
|
<!--启动详细输出-->
|
||||||
|
<verbose>true</verbose>
|
||||||
|
<!--配置jvm参数-->
|
||||||
|
<!-- <jvmArgs>
|
||||||
|
</jvmArgs>-->
|
||||||
|
<!--<agent>
|
||||||
|
<enabled>true</enabled>
|
||||||
|
<options>
|
||||||
|
<option>experimental-class-loader-support</option>
|
||||||
|
</options>
|
||||||
|
</agent>-->
|
||||||
|
</configuration>
|
||||||
|
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
@@ -99,5 +128,4 @@
|
|||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
@@ -0,0 +1,138 @@
|
|||||||
|
package com.bamanker.dailylove.config;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.ClassUtil;
|
||||||
|
import jakarta.annotation.PostConstruct;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.lang.reflect.Constructor;
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 反射将所有项目类扫描加入到服务, 大力出奇迹的操作,感觉不太合适,不过先让服务跑起来
|
||||||
|
*
|
||||||
|
* @author bamanker
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
public class ClassReflectConfig {
|
||||||
|
|
||||||
|
static boolean begin = true;
|
||||||
|
|
||||||
|
@Value("${scanclass}")
|
||||||
|
private Boolean scanclass;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ThreadPoolTaskExecutor executorService;
|
||||||
|
|
||||||
|
@PostConstruct
|
||||||
|
public void init() {
|
||||||
|
|
||||||
|
if (scanclass) {
|
||||||
|
System.err.println("配置文件下 scanclass 开启了生成反射类");
|
||||||
|
} else {
|
||||||
|
System.err.println("配置文件下 scanclass 关闭了生成反射类");
|
||||||
|
}
|
||||||
|
|
||||||
|
synchronized (ClassReflectConfig.class) {
|
||||||
|
if (begin && scanclass) {
|
||||||
|
begin = false;
|
||||||
|
executorService.submit(() -> {
|
||||||
|
|
||||||
|
// {
|
||||||
|
// // 先抓取上一次的文件,生成
|
||||||
|
// try {
|
||||||
|
// BufferedReader utf8Reader = ResourceUtil
|
||||||
|
// .getUtf8Reader("classpath:/META-INF/native-image/reflect-config.json");
|
||||||
|
// String res = utf8Reader.lines().collect(Collectors.joining());
|
||||||
|
// List object = ProJsonUtil.toObject(res, List.class);
|
||||||
|
// for (Object object2 : object) {
|
||||||
|
// try {
|
||||||
|
// Map object22 = (Map) object2;
|
||||||
|
// handlerClass(Class.forName(ProMapUtil.getStr(object22, "name")));
|
||||||
|
// } catch (Exception e) {
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// } catch (Exception e) {
|
||||||
|
// log.error("生成文件异常", e);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
{
|
||||||
|
// 扫描系统第二级开始的包
|
||||||
|
String packageName = ClassReflectConfig.class.getPackageName();
|
||||||
|
String proPackageName = packageName.substring(0,
|
||||||
|
packageName.indexOf(".", packageName.indexOf(".") + 1));
|
||||||
|
|
||||||
|
// 可以在这个地方,添加除了服务以外其他的包,将会加入反射,以供graalvm生成配置
|
||||||
|
List<String> asList = Arrays.asList(proPackageName);
|
||||||
|
|
||||||
|
for (String spn : asList) {
|
||||||
|
try {
|
||||||
|
Set<Class<?>> doScan = ClassUtil.scanPackage(spn);
|
||||||
|
for (Class clazz : doScan) {
|
||||||
|
handlerClass(clazz);
|
||||||
|
}
|
||||||
|
} catch (Throwable e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// handlerClass(RedisMessageListenerContainer.class);
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void handlerClass(Class clazz) {
|
||||||
|
if (clazz.equals(ClassReflectConfig.class)) {
|
||||||
|
// 跳过自己,避免形成循环
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
executorService.submit(() -> {
|
||||||
|
try {
|
||||||
|
System.err.println("反射注入:" + clazz.getName());
|
||||||
|
// 生成所有的构造器
|
||||||
|
Constructor[] declaredConstructors = clazz.getDeclaredConstructors();
|
||||||
|
// 找到无参构造器然后实例化
|
||||||
|
Constructor declaredConstructor = clazz.getDeclaredConstructor();
|
||||||
|
declaredConstructor.setAccessible(true);
|
||||||
|
Object newInstance = declaredConstructor.newInstance();
|
||||||
|
Method[] methods = clazz.getDeclaredMethods();
|
||||||
|
for (Method method : methods) {
|
||||||
|
try {
|
||||||
|
// 实例化成功,那么调用一下
|
||||||
|
method.setAccessible(true);
|
||||||
|
// graalvm必须需要声明方法
|
||||||
|
method.invoke(newInstance);
|
||||||
|
} catch (Throwable e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Field[] fields = clazz.getDeclaredFields();
|
||||||
|
for (Field field : fields) {
|
||||||
|
try {
|
||||||
|
field.setAccessible(true);
|
||||||
|
field.getType();
|
||||||
|
String name = field.getName();
|
||||||
|
field.get(newInstance);
|
||||||
|
|
||||||
|
} catch (Throwable e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
System.err.println("反射注入完成:" + clazz.getName());
|
||||||
|
} catch (Throwable e) {
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -5,7 +5,6 @@ import org.springframework.cloud.context.config.annotation.RefreshScope;
|
|||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@RefreshScope
|
|
||||||
public class DailyLoveConfigure {
|
public class DailyLoveConfigure {
|
||||||
// public static String Access_URL = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={0}&secret={1}";
|
// public static String Access_URL = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={0}&secret={1}";
|
||||||
// public static String Send_URL = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token={0}";
|
// public static String Send_URL = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token={0}";
|
||||||
|
|||||||
@@ -8,9 +8,13 @@ import org.springframework.stereotype.Component;
|
|||||||
@Component
|
@Component
|
||||||
public class PushTask {
|
public class PushTask {
|
||||||
|
|
||||||
@Autowired
|
final
|
||||||
PushDailyController pushDailyController;
|
PushDailyController pushDailyController;
|
||||||
|
|
||||||
|
public PushTask(PushDailyController pushDailyController) {
|
||||||
|
this.pushDailyController = pushDailyController;
|
||||||
|
}
|
||||||
|
|
||||||
//每日 早上7.30,晚上22点 定时推送
|
//每日 早上7.30,晚上22点 定时推送
|
||||||
@Scheduled(cron = "0 30 7 * * ?")
|
@Scheduled(cron = "0 30 7 * * ?")
|
||||||
public void scheduledPushMorning(){
|
public void scheduledPushMorning(){
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import com.bamanker.dailylove.service.DataRemoteClient;
|
|||||||
import com.bamanker.dailylove.service.WechatRequestClient;
|
import com.bamanker.dailylove.service.WechatRequestClient;
|
||||||
import com.bamanker.dailylove.utils.DataUtils;
|
import com.bamanker.dailylove.utils.DataUtils;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
@@ -20,12 +21,17 @@ import java.util.Date;
|
|||||||
@RestController
|
@RestController
|
||||||
public class PushDailyController {
|
public class PushDailyController {
|
||||||
|
|
||||||
@Resource
|
final
|
||||||
DataRemoteClient dataRemoteClient;
|
DataRemoteClient dataRemoteClient;
|
||||||
|
|
||||||
@Resource
|
final
|
||||||
WechatRequestClient wechatRequestClient;
|
WechatRequestClient wechatRequestClient;
|
||||||
|
|
||||||
|
public PushDailyController(DataRemoteClient dataRemoteClient, WechatRequestClient wechatRequestClient) {
|
||||||
|
this.dataRemoteClient = dataRemoteClient;
|
||||||
|
this.wechatRequestClient = wechatRequestClient;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 推送晚安
|
* 推送晚安
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -4,6 +4,9 @@ server:
|
|||||||
spring:
|
spring:
|
||||||
application:
|
application:
|
||||||
name: dailyLove
|
name: dailyLove
|
||||||
|
cloud:
|
||||||
|
refresh:
|
||||||
|
enabled: false
|
||||||
|
|
||||||
DL:
|
DL:
|
||||||
tianxin-key: 72fbbb9e75e338ea6a240e83972f287c
|
tianxin-key: 72fbbb9e75e338ea6a240e83972f287c
|
||||||
@@ -49,4 +52,6 @@ tianxin:
|
|||||||
|
|
||||||
logging:
|
logging:
|
||||||
level:
|
level:
|
||||||
com.bamanker.dailylove.service: debug #指定openfeign日志以什么级别监控哪个接口(可多个)
|
com.bamanker.dailylove.service: debug #指定openfeign日志以什么级别监控哪个接口(可多个)
|
||||||
|
|
||||||
|
scanclass: false
|
||||||
BIN
target/dailylove
Executable file
BIN
target/dailylove
Executable file
Binary file not shown.
Reference in New Issue
Block a user