首页 » spring

maven pom 报错:Failure to find com.tencent.tsf:spring-cloud-tsf-dependencies:pom:1.12.1-Edgware-RELEASE in https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced

1.首先确认你的maven仓库是通的
2.然后检查idea的File ---settings ---build,execution,deployment--maven的settings文件是否正确
3.最后可以mvn -U clean install

spring boot 2 的跨域和1不太一样,具体配置如下
@Configuration
public class CorsConfig implements WebMvcConfigurer {

    @Override
    public void addCorsMappings(CorsRegistry registry) {

        registry.addMapping("/**")
                .allowedOrigins(
                        "*")
                .allowedMethods("GET", "POST", "PUT", "DELETE", "HEAD")
                .allowedHeaders("*")
                .allowCredentials(true);
    }
}

测试跨域,可以用这个链接http://test-cors.org/

embbeded 内嵌 mongodb对于只用来开发测试用的项目很有用

1.添加依赖,前提你是springboot 项目哈

  <dependency>
            <groupId>de.flapdoodle.embed</groupId>
            <artifactId>de.flapdoodle.embed.mongo</artifactId>
            <scope>runtime</scope>
        </dependency>

2.配置mongo的url

spring.data.mongodb.uri=mongodb://localhost:27017/mydb