feat(sj_1.0.0): 修复日志上报问题
This commit is contained in:
parent
84c730844c
commit
4c3fcf73a9
5
pom.xml
5
pom.xml
@ -115,6 +115,11 @@
|
||||
<artifactId>hutool-crypto</artifactId>
|
||||
<version>${hutool-all.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-core</artifactId>
|
||||
<version>${hutool-all.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.aizuda</groupId>
|
||||
<artifactId>snail-job-client-retry-core</artifactId>
|
||||
|
@ -1,46 +0,0 @@
|
||||
package com.aizuda.snailjob.common.core.alarm.email;
|
||||
|
||||
import cn.hutool.core.io.IORuntimeException;
|
||||
|
||||
/**
|
||||
* 全局邮件帐户,依赖于邮件配置文件{@link MailAccount#MAIL_SETTING_PATHS}
|
||||
*
|
||||
* @author looly
|
||||
*/
|
||||
public enum GlobalMailAccount {
|
||||
INSTANCE;
|
||||
|
||||
private final MailAccount mailAccount;
|
||||
|
||||
/**
|
||||
* 构造
|
||||
*/
|
||||
GlobalMailAccount() {
|
||||
mailAccount = createDefaultAccount();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得邮件帐户
|
||||
*
|
||||
* @return 邮件帐户
|
||||
*/
|
||||
public MailAccount getAccount() {
|
||||
return this.mailAccount;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建默认帐户
|
||||
*
|
||||
* @return MailAccount
|
||||
*/
|
||||
private MailAccount createDefaultAccount() {
|
||||
for (String mailSettingPath : MailAccount.MAIL_SETTING_PATHS) {
|
||||
try {
|
||||
return new MailAccount(mailSettingPath);
|
||||
} catch (IORuntimeException ignore) {
|
||||
//ignore
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@ -4,6 +4,7 @@ import cn.hutool.core.builder.Builder;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.io.IORuntimeException;
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
@ -22,6 +23,7 @@ import jakarta.mail.util.ByteArrayDataSource;
|
||||
import java.io.*;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.Date;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 邮件发送客户端
|
||||
@ -89,32 +91,17 @@ public class Mail implements Builder<MimeMessage> {
|
||||
return new Mail(mailAccount);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建邮件客户端,使用全局邮件帐户
|
||||
*
|
||||
* @return Mail
|
||||
*/
|
||||
public static Mail create() {
|
||||
return new Mail();
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------- Constructor start
|
||||
|
||||
/**
|
||||
* 构造,使用全局邮件帐户
|
||||
*/
|
||||
public Mail() {
|
||||
this(GlobalMailAccount.INSTANCE.getAccount());
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造
|
||||
*
|
||||
* @param mailAccount 邮件帐户,如果为null使用默认配置文件的全局邮件配置
|
||||
* @param mailAccount 邮件帐户
|
||||
*/
|
||||
public Mail(MailAccount mailAccount) {
|
||||
mailAccount = (null != mailAccount) ? mailAccount : GlobalMailAccount.INSTANCE.getAccount();
|
||||
this.mailAccount = mailAccount.defaultIfEmpty();
|
||||
Assert.notNull(mailAccount, () -> new MailException("邮件账号不能为空"));
|
||||
this.mailAccount = mailAccount;
|
||||
}
|
||||
// --------------------------------------------------------------- Constructor end
|
||||
|
||||
|
@ -3,7 +3,6 @@ package com.aizuda.snailjob.common.core.alarm.email;
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.setting.Setting;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
@ -39,14 +38,10 @@ public class MailAccount implements Serializable {
|
||||
|
||||
// System Properties
|
||||
private static final String SPLIT_LONG_PARAMS = "mail.mime.splitlongparameters";
|
||||
//private static final String ENCODE_FILE_NAME = "mail.mime.encodefilename";
|
||||
//private static final String CHARSET = "mail.mime.charset";
|
||||
|
||||
// 其他
|
||||
private static final String MAIL_DEBUG = "mail.debug";
|
||||
|
||||
public static final String[] MAIL_SETTING_PATHS = new String[]{"config/mail.setting", "config/mailAccount.setting", "mail.setting"};
|
||||
|
||||
/**
|
||||
* SMTP服务器域名
|
||||
*/
|
||||
@ -142,23 +137,6 @@ public class MailAccount implements Serializable {
|
||||
public MailAccount() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造
|
||||
*
|
||||
* @param settingPath 配置文件路径
|
||||
*/
|
||||
public MailAccount(String settingPath) {
|
||||
this(new Setting(settingPath));
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造
|
||||
*
|
||||
* @param setting 配置文件
|
||||
*/
|
||||
public MailAccount(Setting setting) {
|
||||
setting.toBean(this);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------- Constructor end
|
||||
|
||||
|
@ -1,22 +1,14 @@
|
||||
package com.aizuda.snailjob.common.core.alarm.strategy;
|
||||
|
||||
import com.aizuda.snailjob.common.core.alarm.SnailJobAlarmFactory;
|
||||
import com.aizuda.snailjob.common.core.alarm.attribute.EmailAttribute;
|
||||
import com.aizuda.snailjob.common.core.alarm.email.MailAccount;
|
||||
import com.aizuda.snailjob.common.core.alarm.email.MailProperties;
|
||||
import com.aizuda.snailjob.common.core.context.SpringContext;
|
||||
import com.aizuda.snailjob.common.core.util.MailUtils;
|
||||
import com.aizuda.snailjob.common.core.enums.AlarmTypeEnum;
|
||||
import com.aizuda.snailjob.common.core.alarm.AlarmContext;
|
||||
import com.aizuda.snailjob.common.core.util.JsonUtil;
|
||||
import com.aizuda.snailjob.common.log.SnailJobLog;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.context.annotation.DependsOn;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.core.env.StandardEnvironment;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -28,10 +28,6 @@
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-extra</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-log4j2</artifactId>
|
||||
@ -42,6 +38,10 @@
|
||||
<artifactId>log4j</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-core</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
Loading…
Reference in New Issue
Block a user