调整nacos配置中心
This commit is contained in:
@@ -11,6 +11,24 @@
|
||||
|
||||
<artifactId>service-product</artifactId>
|
||||
<dependencies>
|
||||
|
||||
<!-- #低版本的okhttp会报错提示-->
|
||||
<dependency>
|
||||
<groupId>com.squareup.okhttp3</groupId>
|
||||
<artifactId>okhttp</artifactId>
|
||||
<version>4.9.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.minio</groupId>
|
||||
<artifactId>minio</artifactId>
|
||||
<version>8.5.6</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>okhttp</artifactId>
|
||||
<groupId>com.squareup.okhttp3</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<!-- 阿里云oss依赖 -->
|
||||
<dependency>
|
||||
<groupId>com.aliyun.oss</groupId>
|
||||
|
@@ -40,7 +40,7 @@ public interface SkuInfoMapper extends BaseMapper<SkuInfo> {
|
||||
*/
|
||||
void unlockStock(@Param("skuId") Long skuId, @Param("skuNum") Integer skuNum);
|
||||
|
||||
/**
|
||||
/**z
|
||||
* 减库存
|
||||
*
|
||||
* @param skuId
|
||||
|
@@ -1,8 +1,7 @@
|
||||
package com.atguigu.ssyx.product.service.impl;
|
||||
|
||||
import com.aliyun.oss.OSS;
|
||||
import com.aliyun.oss.OSSClientBuilder;
|
||||
import com.atguigu.ssyx.product.service.FileUploadService;
|
||||
import io.minio.MinioClient;
|
||||
import org.joda.time.DateTime;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -35,7 +34,12 @@ public class FileUploadServiceImpl implements FileUploadService {
|
||||
public String fileUpload(MultipartFile file) throws Exception {
|
||||
try {
|
||||
// 创建OSSClient实例。
|
||||
OSS ossClient = new OSSClientBuilder().build(endPoint, accessKey, secreKey);
|
||||
// OSS ossClient = new OSSClientBuilder().build(endPoint, accessKey, secreKey);
|
||||
MinioClient minioClient =
|
||||
MinioClient.builder()
|
||||
.endpoint("https://play.min.io")
|
||||
.credentials("Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG")
|
||||
.build();
|
||||
// 上传文件流。
|
||||
InputStream inputStream = file.getInputStream();
|
||||
String fileName = file.getOriginalFilename();
|
||||
@@ -50,9 +54,9 @@ public class FileUploadServiceImpl implements FileUploadService {
|
||||
String timeUrl = new DateTime().toString("yyyy/MM/dd");
|
||||
fileName = timeUrl + "/" + fileName;
|
||||
//调用方法实现上传
|
||||
ossClient.putObject(bucketName, fileName, inputStream);
|
||||
// ossClient.putObject(bucketName, fileName, inputStream);
|
||||
// 关闭OSSClient。
|
||||
ossClient.shutdown();
|
||||
// ossClient.shutdown();
|
||||
//上传之后文件路径
|
||||
String url = "https://" + bucketName + "." + endPoint + "/" + fileName;
|
||||
//返回
|
||||
|
@@ -0,0 +1,45 @@
|
||||
package com.atguigu.ssyx.product.utils;
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
* ClassName: FileUploader
|
||||
* Package: com.atguigu.ssyx.product.utils
|
||||
*
|
||||
* @author yovinchen
|
||||
* @Create 2023/10/13 17:55
|
||||
*/
|
||||
public class FileUploader {
|
||||
|
||||
public static void main(String[] args) throws IOException, NoSuchAlgorithmException, InvalidKeyException {
|
||||
try {
|
||||
// Create a minioClient with the MinIO server playground, its access key and secret key.
|
||||
MinioClient minioClient = MinioClient.builder().endpoint("http://154.9.228.206:9000").credentials("IaZk6fqBYY66dcE03edv", "6zzVxP6wAuu74Tft22JJZDQGVfnaHtJ221XjAwQu").build();
|
||||
|
||||
// Make 'asiatrip' bucket if not exist.
|
||||
boolean found = minioClient.bucketExists(BucketExistsArgs.builder().bucket("public").build());
|
||||
if (!found) {
|
||||
// Make a new bucket called 'asiatrip'.
|
||||
minioClient.makeBucket(MakeBucketArgs.builder().bucket("public").build());
|
||||
} else {
|
||||
System.out.println("Bucket 'public' already exists.");
|
||||
}
|
||||
|
||||
// Upload '/home/user/Photos/asiaphotos.zip' as object name 'asiaphotos-2015.zip' to bucket
|
||||
// 'asiatrip'.
|
||||
minioClient.uploadObject(UploadObjectArgs.builder().bucket("public").object("credentials.json").filename("C:/Users/lai.huanxiong/Downloads/credentials.json").build());
|
||||
System.out.println("'C:/Users/lai.huanxiong/Downloads/credentials.json' is successfully uploaded as " + "object 'credentials.json' to bucket 'public'.");
|
||||
} catch (MinioException e) {
|
||||
System.out.println("Error occurred: " + e);
|
||||
System.out.println("HTTP trace: " + e.httpTrace());
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,48 +0,0 @@
|
||||
server:
|
||||
port: 8203
|
||||
|
||||
mybatis-plus:
|
||||
configuration:
|
||||
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
||||
type-enums-package: com.atguigu.ssyx.enums
|
||||
spring:
|
||||
datasource:
|
||||
type: com.zaxxer.hikari.HikariDataSource
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
url: jdbc:mysql://82.157.68.223:3306/shequ-product?characterEncoding=utf-8&useSSL=false
|
||||
username: shequ-product
|
||||
password: shequ-product
|
||||
rabbitmq:
|
||||
host: 43.143.164.194
|
||||
port: 5672
|
||||
username: guest
|
||||
password: guest
|
||||
publisher-confirm-type: CORRELATED #发布确认模式,消息是否被成功发送到交换机
|
||||
publisher-returns: true
|
||||
listener:
|
||||
simple:
|
||||
prefetch: 1
|
||||
concurrency: 3
|
||||
acknowledge-mode: manual #消费端手动确认
|
||||
redis:
|
||||
host: 82.157.68.223
|
||||
port: 6379
|
||||
database: 0
|
||||
timeout: 1800000
|
||||
password:
|
||||
lettuce:
|
||||
pool:
|
||||
max-active: 20 #最大连接数
|
||||
max-wait: -1 #最大阻塞等待时间(负数表示没限制)
|
||||
max-idle: 5 #最大空闲
|
||||
min-idle: 0 #最小空闲
|
||||
jackson:
|
||||
date-format: yyyy-MM-dd HH:mm:ss
|
||||
time-zone: GMT+8
|
||||
|
||||
aliyun:
|
||||
endpoint: oss-cn-beijing.aliyuncs.com
|
||||
keyid: LTAI5tHWGPq6o62dMMV1hn1i
|
||||
keysecret: FyUK59nlI0bf1MFHLuEvtBwXl2CJjA
|
||||
bucketname: ssyx-yovinchen
|
||||
|
@@ -1,8 +1,8 @@
|
||||
server:
|
||||
port: 8203
|
||||
spring:
|
||||
application:
|
||||
name: service-product
|
||||
profiles:
|
||||
active: dev
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
|
@@ -0,0 +1,31 @@
|
||||
spring:
|
||||
cloud:
|
||||
nacos:
|
||||
config:
|
||||
namespace: dd5265c5-8290-45bc-9d07-395c14c977d3
|
||||
server-addr: 82.157.68.223:8848
|
||||
group: service
|
||||
username: nacos
|
||||
password: nacos
|
||||
enabled: true
|
||||
file-extension: yml
|
||||
extension-configs:
|
||||
- data-id: common.yml
|
||||
group: common
|
||||
refresh: true
|
||||
- data-id: service-redis.yml
|
||||
group: common
|
||||
refresh: true
|
||||
- data-id: service-rabbitmq.yml
|
||||
group: common
|
||||
refresh: true
|
||||
- data-id: config-rabbitmq.yml
|
||||
group: config
|
||||
refresh: true
|
||||
- data-id: service-openfeign.yml
|
||||
group: common
|
||||
refresh: true
|
||||
- data-id: oss-aliyun.yml
|
||||
group: oss
|
||||
refresh: true
|
||||
|
Reference in New Issue
Block a user