fastapi 启动之前执行代码,旧版本使用的是@app.on_event("startup")
,不过在已经不推荐使用
将仓库下某个模块复制到新仓库并保留提交记录(非子库)
在Git中,有时候我们需要将一个仓库中的某个模块复制到另一个仓库中,并且还需要保留提交记录。这个时候我们可以使用Git subtree命令来实现。
例如:将本地某个仓库中的design-pattern
文件夹下的所有文件拿出来作为一个新仓库
08S01-Communications link failure
IDEA Datebase 突然查询数据库失败,提示08S01错误
[08S01] Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
Stop Using TODO for Everything
【转发】Stop Using TODO for Everything (停止使用 TODO 处理所有事情)
很多程序员习惯在代码注释写 TODO,表示待完成的任务。作者建议不要再写 TODO,而用具体的任务替代,比如需要添加文档写"DOCME",需要添加测试写"TESTME"。
并不是说“注释不好”,或者“你应该只使用问题跟踪器”。而是有一些方便的,更具描述性的替代方案:
Stop Writing Code Comments
【转发】Stop Writing Code Comments(请停止代码注释)
https://blog.usejournal.com/stop-writing-code-comments-28fef5272752
代码中写注释是不可避免的,作者主要意指不要写多余的注释,如果你的需要写很多的注释,意味着你应该考虑重构你的代码,而不是增加注释
多文档实例添加导航
docusaurus 创建后有一个预设的默认文档docs
,但是如果我们想想添加额外的文档就需要使用到 docusaurus 多文档实例。
Error creating bean with name
[ERROR] Error creating bean with name 'aliCloudEdasSdk' defined in class path resource
环境
spring-cloud-alibaba-dependencies 2021.0.1.0
gulimall-common pom.xml
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>aliyun-oss-spring-boot-starter</artifactId>
</dependency>
....
<dependencyManagement>
<dependenies>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>aliyun-spring-boot-dependencies</artifactId>
<version>1.0.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
gulimall-product pom.xml
<dependency>
<groupId>com.atguigu.gulimall</groupId>
<artifactId>gulimall-common</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
错误提示
2022-04-18 21:15:08.104 WARN 79340 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'aliCloudEdasSdk' defined in class path resource [com/alibaba/cloud/spring/boot/context/autoconfigure/EdasContextAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.alibaba.cloud.context.edas.AliCloudEdasSdk]: Factory method 'aliCloudEdasSdk' threw exception; nested exception is java.lang.NoSuchMethodError: com.aliyuncs.profile.DefaultProfile.getHttpClientConfig()Lcom/aliyuncs/http/HttpClientConfig;
***************************
APPLICATION FAILED TO START
***************************
Description:
An attempt was made to call a method that does not exist. The attempt was made from the following location:
com.alibaba.cloud.context.AliCloudSdk.<init>(AliCloudSdk.java:76)
The following method did not exist:
com.aliyuncs.profile.DefaultProfile.getHttpClientConfig()Lcom/aliyuncs/http/HttpClientConfig;
The calling method's class, com.alibaba.cloud.context.AliCloudSdk, was loaded from the following location:
jar:file:/Users/xiaoming/local/.m2/repository/com/alibaba/cloud/alicloud-context/1.0.5/alicloud-context-1.0.5.jar!/com/alibaba/cloud/context/AliCloudSdk.class
The called method's class, com.aliyuncs.profile.DefaultProfile, is available from the following locations:
jar:file:/Users/xiaoming/local/.m2/repository/com/aliyun/aliyun-java-sdk-core/3.4.0/aliyun-java-sdk-core-3.4.0.jar!/com/aliyuncs/profile/DefaultProfile.class
The called method's class hierarchy was loaded from the following locations:
com.aliyuncs.profile.DefaultProfile: file:/Users/xiaoming/local/.m2/repository/com/aliyun/aliyun-java-sdk-core/3.4.0/aliyun-java-sdk-core-3.4.0.jar
Action:
Correct the classpath of your application so that it contains compatible versions of the classes com.alibaba.cloud.context.AliCloudSdk and com.aliyuncs.profile.DefaultProfile
根据提示是因为 aliyun-java-sdk-core-3.4.0.jar 这个包没有指定的方法
通过查看idea 查看 maven depenencies 依赖图发现 aliyun-java-sdk-core 并没有爆红显示冲突, 不过我们将鼠标放在 aliyun-java-sdk-core 看到版本显示为 4.5.0,而点进去看到的版本却是3.4.0。 说明 aliyun-oss-spring-boot-starter 中引入的是3.4.0版本,那么这个4.5.0版本在哪里呢? 在 aliyun-spring-boot-dependencies 依赖管理组件中发现引入的是4.5.0
解决办法
上面已经找到冲突的包 那么只需要排除3.4.0 即可 (可不单独再引入 4.5.0)
<!-- 阿里云 oss -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>aliyun-oss-spring-boot-starter</artifactId>
<exclusions>
<exclusion>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-core</artifactId>
</exclusion>
</exclusions>
</dependency>
部署到AWS
背景插图
一个开源的在线插图网站, 可以个人免费使用或商用