上传maven配置

release
WangQi 2 years ago
parent 32f44fd483
commit b489d45086
  1. 11
      order-management-common/pom.xml
  2. 5
      order-management-consumer/pom.xml
  3. 6
      order-management-consumer/src/main/resources/bootstrap-dev.yaml
  4. 5
      order-management-consumer/src/main/resources/bootstrap-std.yaml
  5. 4
      order-management-consumer/src/main/resources/bootstrap.yaml
  6. 199
      order-management-consumer/src/test/java/Pop3Test.java
  7. 38
      pom.xml

@ -95,5 +95,14 @@
</dependencies>
<distributionManagement>
<repository>
<id>nexus-myself</id>
<url>http://172.31.32.53:8081/repository/sndt-local</url>
</repository>
<snapshotRepository>
<id>nexus-myself</id>
<url>http://172.31.32.53:8081/repository/sndt-local</url>
</snapshotRepository>
</distributionManagement>
</project>

@ -504,6 +504,11 @@
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
</dependency>
</dependencies>
<build>
<finalName>order-api</finalName>

@ -4,15 +4,15 @@ spring:
nacos:
config:
# Nacos config 地址
server-addr: 10.1.1.72:8848
server-addr: 172.31.36.147:33000
# Nacos config 命名空间,对应配置中的名称(sims_order_namespace)
namespace: sdenergy-order
namespace: a049b41c-b0a8-4a66-91b1-f3f3cab0e524
# Nacos config 分组
group: sims-order-config
# Nacos config 登录用户名
username: nacos
# Nacos config 登录密码
password: nacos
password: Invoice.nacos.!1
# Nacos config 配置文件前缀
prefix: sims-order-api
# Nacos config 配置文件后缀,拼接完URL需要对应NacosServer中的dataId对应配置,${prefix}-${spring.profiles.active}.${file-extension}

@ -4,13 +4,14 @@ spring:
nacos:
config:
# Nacos config 地址
server-addr: nacos-1.itax.local:33000
# server-addr: nacos-1.itax.local:33000
server-addr: 172.31.36.147:33000
# Nacos config 命名空间,对应配置中的名称(sims_order_namespace)
namespace: a049b41c-b0a8-4a66-91b1-f3f3cab0e524
# Nacos config 分组
group: sims-order-config
# Nacos config 登录用户名
username: admin
username: nacos
# Nacos config 登录密码
password: Invoice.nacos.!1
# Nacos config 配置文件前缀

@ -6,7 +6,9 @@ spring:
name: order-api
profiles:
# Spring 配置文件读取
active: @deployType@
# active: @deployType@
# active: dev
active: std
#active: test
jackson:
# jackson 日期格式化

@ -0,0 +1,199 @@
import com.sun.mail.pop3.POP3Folder;
import com.sun.mail.pop3.POP3Store;
import com.sun.mail.util.MailSSLSocketFactory;
import org.junit.Test;
import javax.mail.*;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMultipart;
import javax.mail.internet.MimeUtility;
import javax.mail.search.FlagTerm;
import java.io.*;
import java.security.GeneralSecurityException;
import java.text.SimpleDateFormat;
import java.util.Properties;
public class Pop3Test {
@Test
public void main() throws Exception {
POP3Store pop3Store = null;
try {
Session session = setCollectProperties();
pop3Store = (POP3Store)session.getStore("pop3");
pop3Store.connect("pop.qq.com", 995, "1021674882@qq.com", "szcrvcsoakumbcid");
POP3Folder pop3Folder = (POP3Folder) pop3Store.getFolder("INBOX");
pop3Folder.open(Folder.READ_WRITE); //打开收件箱
FetchProfile fetchProfile = new FetchProfile();
fetchProfile.add(FetchProfile.Item.ENVELOPE);
FlagTerm flagTerm = new FlagTerm(new Flags(Flags.Flag.SEEN),false);
Message[] messages = pop3Folder.search(flagTerm);
pop3Folder.fetch(messages,fetchProfile);
int length = messages.length;
System.out.println("收件箱的邮件数:" + length);
Folder folder = pop3Folder.getStore().getDefaultFolder();
Folder[] folders = folder.list();
for (int i = 0; i < folders.length; i++) {
System.out.println("名称:"+folders[i].getName());
}
for (int i = 0; i < length; i++) {
MimeMessage msg = (MimeMessage) messages[i];
String from = MimeUtility.decodeText(messages[i].getFrom()[0].toString());
InternetAddress ia = new InternetAddress(from);
System.out.println("发件人:" + ia.getPersonal() + '(' + ia.getAddress() + ')');
System.out.println("主题:" + messages[i].getSubject());
System.out.println("邮件发送时间:" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(messages[i].getSentDate()));
boolean isContainerAttachment = isContainAttachment(msg);
System.out.println("是否包含附件:" + isContainerAttachment);
if (isContainerAttachment) {
//设置需要保存的目录并保存附件
// saveAttachment(msg, "F:\\test\\"+msg.getSubject() + "_"+i+"_"); //保存附件
}
messages[i].setFlag(Flags.Flag.SEEN, true);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if(pop3Store != null){
pop3Store.close();
}
}
}
/**
* 设置连接邮箱属性
* @return
* @throws GeneralSecurityException
*/
private static Session setCollectProperties() throws GeneralSecurityException {
Properties props = new Properties();
props.setProperty("mail.popStore.protocol", "pop3"); // 使用pop3协议
props.setProperty("mail.pop3.port", "995"); // 端口
MailSSLSocketFactory sf = new MailSSLSocketFactory();
sf.setTrustAllHosts(true);
props.put("mail.pop3.ssl.enable",true);
props.put("mail.pop3.ssl.socketFactory",sf);
props.setProperty("mail.pop3.host", "pop.qq.com");
return Session.getInstance(props);
}
/**
* 判断邮件中是否包含附件
* @param
* @return 邮件中存在附件返回true不存在返回false
* @throws MessagingException
* @throws Exception
*/
public static boolean isContainAttachment(Part part) throws Exception {
boolean flag = false;
if (part.isMimeType("multipart/*")) {
MimeMultipart multipart = (MimeMultipart) part.getContent();
int partCount = multipart.getCount();
for (int i = 0; i < partCount; i++) {
BodyPart bodyPart = multipart.getBodyPart(i);
String disp = bodyPart.getDisposition();
if (disp != null && (disp.equalsIgnoreCase(Part.ATTACHMENT) || disp.equalsIgnoreCase(Part.INLINE))) {
flag = true;
} else if (bodyPart.isMimeType("multipart/*")) {
flag = isContainAttachment(bodyPart);
} else {
String contentType = bodyPart.getContentType();
if (contentType.indexOf("application") != -1) {
flag = true;
}
if (contentType.indexOf("name") != -1) {
flag = true;
}
}
if (flag) break;
}
} else if (part.isMimeType("message/rfc822")) {
flag = isContainAttachment((Part)part.getContent());
}
return flag;
}
/**
* 保存附件
* @param part 邮件中多个组合体中的其中一个组合体
* @param destDir 附件保存目录
* @throws UnsupportedEncodingException
* @throws MessagingException
* @throws FileNotFoundException
* @throws IOException
*/
public static void saveAttachment(Part part, String destDir) throws Exception{
if (part.isMimeType("multipart/*")) {
Multipart multipart = (Multipart) part.getContent(); //复杂体邮件
//复杂体邮件包含多个邮件体
int partCount = multipart.getCount();
for (int i = 0; i < partCount; i++) {
//获得复杂体邮件中其中一个邮件体
BodyPart bodyPart = multipart.getBodyPart(i);
//某一个邮件体也有可能是由多个邮件体组成的复杂体
String disp = bodyPart.getDisposition();
if (disp != null && (disp.equalsIgnoreCase(Part.ATTACHMENT) || disp.equalsIgnoreCase(Part.INLINE))) {
InputStream is = bodyPart.getInputStream();
saveFile(is, destDir, decodeText(bodyPart.getFileName()));
} else if (bodyPart.isMimeType("multipart/*")) {
saveAttachment(bodyPart,destDir);
} else {
String contentType = bodyPart.getContentType();
if (contentType.indexOf("name") != -1 || contentType.indexOf("application") != -1) {
saveFile(bodyPart.getInputStream(), destDir, decodeText(bodyPart.getFileName()));
}
}
}
} else if (part.isMimeType("message/rfc822")) {
saveAttachment((Part) part.getContent(),destDir);
}
}
/**
* 读取输入流中的数据保存至指定目录
* @param is 输入流
* @param fileName 文件名
* @param destDir 文件存储目录
* @throws Exception
*/
private static void saveFile(InputStream is, String destDir, String fileName)
throws Exception {
//如果文件名称包含关键字则进行保存
BufferedInputStream bis = new BufferedInputStream(is);
BufferedOutputStream bos = new BufferedOutputStream(
new FileOutputStream(new File(destDir + fileName)));
int len = -1;
while ((len = bis.read()) != -1) {
bos.write(len);
bos.flush();
}
bos.close();
bis.close();
}
/**
* 文本解码
* @param encodeText 解码MimeUtility.encodeText(String text)方法编码后的文本
* @return 解码后的文本
* @throws UnsupportedEncodingException
*/
public static String decodeText(String encodeText) throws UnsupportedEncodingException {
if (encodeText == null || "".equals(encodeText)) {
return "";
} else {
return MimeUtility.decodeText(encodeText);
}
}
}

@ -148,15 +148,22 @@
<!-- hibernate.validator版本-->
<hibernate.validator.version>6.1.6.Final</hibernate.validator.version>
<repository.url>http://10.1.20.6:8081/nexus/content/groups/public</repository.url>
<pluginRepositories.url>http://10.1.20.6:8081/nexus/content/groups/public</pluginRepositories.url>
<!-- <repository.url>http://10.1.20.6:8081/nexus/content/groups/public</repository.url>-->
<!-- <pluginRepositories.url>http://10.1.20.6:8081/nexus/content/groups/public</pluginRepositories.url>-->
<distribution.repository.release.url>http://10.1.20.6:8081/nexus/content/repositories/releases
<!-- <distribution.repository.release.url>http://10.1.20.6:8081/nexus/content/repositories/releases-->
<!-- </distribution.repository.release.url>-->
<!-- <distribution.repository.snapshot.url>http://10.1.20.6:8081/nexus/content/repositories/snapshots-->
<!-- </distribution.repository.snapshot.url>-->
<repository.url>http://172.31.32.53:8081/repository/maven-public</repository.url>
<pluginRepositories.url>http://172.31.32.53:8081/repository/maven-public</pluginRepositories.url>
<distribution.repository.release.url>http://172.31.32.53:8081/repository/maven-public
</distribution.repository.release.url>
<distribution.repository.snapshot.url>http://10.1.20.6:8081/nexus/content/repositories/snapshots
<distribution.repository.snapshot.url>http://172.31.32.53:8081/repository/maven-public
</distribution.repository.snapshot.url>
</properties>
<modules>
@ -568,9 +575,9 @@
</distribution.repository.snapshot.url>
</properties>
<!-- 默认激活 -->
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<!-- <activation>-->
<!-- <activeByDefault>true</activeByDefault>-->
<!-- </activation>-->
</profile>
<!-- 测试环境 -->
<profile>
@ -663,14 +670,17 @@
<![CDATA[jdbc:mysql://10.1.2.226:3306/sales_manager?useUnicode=true&amp;characterEncoding=utf8&amp;useSSL=false&amp;serverTimezone=Asia/Shanghai&amp;allowMultiQueries=true]]></logback.mysql.url>
<logback.mysql.user>dxhy</logback.mysql.user>
<logback.mysql.pwd>Dxhy@123</logback.mysql.pwd>
<repository.url>http://10.1.20.6:8081/nexus/content/groups/public</repository.url>
<pluginRepositories.url>http://10.1.20.6:8081/nexus/content/groups/public</pluginRepositories.url>
<!-- <repository.url>http://172.31.32.53:8081/repository/maven-public</repository.url>-->
<!-- <pluginRepositories.url>http://172.31.32.53:8081/repository/maven-public</pluginRepositories.url>-->
<distribution.repository.release.url>http://10.1.20.6:8081/nexus/content/repositories/releases
</distribution.repository.release.url>
<distribution.repository.snapshot.url>http://10.1.20.6:8081/nexus/content/repositories/snapshots
</distribution.repository.snapshot.url>
<!-- <distribution.repository.release.url>http://172.31.32.53:8081/repository/maven-public-->
<!-- </distribution.repository.release.url>-->
<!-- <distribution.repository.snapshot.url>http://172.31.32.53:8081/repository/maven-public-->
<!-- </distribution.repository.snapshot.url>-->
</properties>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile>
<!-- 正式环境 -->
<profile>

Loading…
Cancel
Save