1. 程式人生 > 其它 >使用oss上傳出現的錯誤

使用oss上傳出現的錯誤

問題提示:

Found multiple occurrences of org.json.JSONObject on the class path:

	jar:file:/D:/document/maven/repository/org/json/json/20170516/json-20170516.jar!/org/json/JSONObject.class
	jar:file:/D:/document/maven/repository/com/vaadin/external/google/android-json/0.0.20131108.vaadin1/android-json-0.0.20131108.vaadin1.jar!/org/json/JSONObject.class

You may wish to exclude one of them to ensure predictable runtime behavior

 環境配置:

<dependency>
    <groupId>com.alibaba.cloud</groupId>
    <artifactId>spring-cloud-starter-alicloud-oss</artifactId>
</dependency>

相關程式碼:

@Autowired
    OSSClient ossClient;

@Test
    public void testUpload() throws FileNotFoundException {

        InputStream inputStream 
= new FileInputStream("E:\\13.jpg"); // 填寫Bucket名稱和Object完整路徑。Object完整路徑中不能包含Bucket名稱。 ossClient.putObject("market-gulimall", "13.jpg", inputStream); // 關閉OSSClient。 ossClient.shutdown(); System.out.println("上傳成功");
}

解決辦法:

將OSSClient 注入修改成OSS