Browse Source

增加数据源配置

dev-jl
wxc 2 years ago
parent
commit
274d8895f3
  1. 5
      mailbox-common/pom.xml
  2. 8
      mailbox-common/src/main/java/com/biutag/exception/MinioOperateException.java
  3. 46
      mailbox-common/src/main/java/com/biutag/util/MinioUtil.java
  4. 9
      mailbox-lan/src/main/resources/application.yml
  5. 2
      mailbox-outer-admin/src/main/java/com/biutag/outeradmin/OuterAdminApplication.java
  6. 2
      mailbox-outer/src/main/resources/application.yml
  7. 6
      pom.xml

5
mailbox-common/pom.xml

@ -27,6 +27,11 @@
<optional>true</optional>
</dependency>
<dependency>
<groupId>io.minio</groupId>
<artifactId>minio</artifactId>
</dependency>
</dependencies>
</project>

8
mailbox-common/src/main/java/com/biutag/exception/MinioOperateException.java

@ -0,0 +1,8 @@
package com.biutag.exception;
public class MinioOperateException extends RuntimeException {
public MinioOperateException(Throwable cause) {
super(cause);
}
}

46
mailbox-common/src/main/java/com/biutag/util/MinioUtil.java

@ -0,0 +1,46 @@
package com.biutag.util;
import com.biutag.exception.MinioOperateException;
import io.minio.BucketExistsArgs;
import io.minio.MakeBucketArgs;
import io.minio.MinioClient;
import io.minio.UploadObjectArgs;
import io.minio.errors.MinioException;
import java.io.IOException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
public class MinioUtil {
public static void main(String[] args) {
// 设置MinIO服务器的端点、Access Key和Secret Key
String endpoint = "http://172.31.217.20:31813";
String accessKey = "your-access-key";
String secretKey = "your-secret-key";
try {
// 创建MinIO客户端
MinioClient minioClient = MinioClient.builder()
.endpoint(endpoint)
.credentials(accessKey, secretKey)
.build();
// 检查存储桶是否存在,如果不存在则创建
String bucketName = "mailbox";
BucketExistsArgs bucketExistsArgs = BucketExistsArgs.builder()
.bucket(bucketName)
// 添加额外的选项
.build();
if (!minioClient.bucketExists(bucketExistsArgs)) {
MakeBucketArgs makeBucketArgs = MakeBucketArgs.builder().bucket(bucketName).build();
minioClient.makeBucket(makeBucketArgs);
}
// 上传文件到MinIO服务器
String objectName = "your-object-name";
String filePath = "path/to/your/file.txt";
UploadObjectArgs uploadObjectArgs = UploadObjectArgs.builder().bucket(bucketName).object(objectName).filename(filePath).build();
minioClient.uploadObject(uploadObjectArgs);
} catch (MinioException | IOException | NoSuchAlgorithmException | InvalidKeyException e) {
throw new MinioOperateException(e.getCause());
}
}
}

9
mailbox-lan/src/main/resources/application.yml

@ -2,4 +2,11 @@ server:
port: 8081
tongweb:
license:
path: license/license.dat
path: license/license.dat
spring:
datasource:
driver-class-name: org.postgresql.Driver
url: jdbc:postgresql://172.31.217.20:32378/mailbox?currentSchema=mailbox
username: mailbox
password: Ip12341234

2
mailbox-outer-admin/src/main/java/com/biutag/outeradmin/OuterAdminApplication.java

@ -10,4 +10,4 @@ public class OuterAdminApplication {
SpringApplication.run(OuterAdminApplication.class, args);
}
}
}

2
mailbox-outer/src/main/resources/application.yml

@ -8,5 +8,5 @@ spring:
datasource:
driver-class-name: org.postgresql.Driver
url: jdbc:postgresql://172.31.217.20:32378/mailbox?currentSchema=mailbox-outer
username: vbadmin
username: mailbox
password: Ip12341234

6
pom.xml

@ -69,6 +69,12 @@
<version>5.8.25</version>
</dependency>
<dependency>
<groupId>io.minio</groupId>
<artifactId>minio</artifactId>
<version>8.5.7</version>
</dependency>
</dependencies>
</dependencyManagement>

Loading…
Cancel
Save