callicoder / spring-boot-react-oauth2-social-login-demo

Spring Boot React OAuth2 Social Login with Google, Facebook, and Github
1.45k stars 700 forks source link

The problem of "mvn spring-boot:run" #47

Closed LeeZChuan closed 3 years ago

LeeZChuan commented 3 years ago

Hi!

when i use "mvn spring-boot:run"

[INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.2.1.RELEASE:run (default-cli) on project spring-social: Application finished with exit code: 1 -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

what can i do for this problem?

DarshanMaradiya commented 3 years ago

I'm not sure if this will work, but try this:

In package com.example.springsocial.config.WebMvcConfig:

Update the following

    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**")
        .allowedOrigins("*")
        .allowedMethods("GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS")
        .allowedHeaders("*")
        .allowCredentials(true)
        .maxAge(MAX_AGE_SECS);
    }

with the following:

    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**")
        // .allowedOrigins("*")
        .allowedOriginPatterns("/**")
        .allowedMethods("GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS")
        .allowedHeaders("*")
        .allowCredentials(true)
        .maxAge(MAX_AGE_SECS);
    }

My Spring Boot version is 2.4.0

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.4.0</version>
    <relativePath/>
</parent>
LeeZChuan commented 3 years ago

thanks!

DarshanMaradiya commented 3 years ago

Did it work?

LeeZChuan commented 3 years ago

oh, it‘s too late to look at your reply, I write a new system by myself. So i did not continue to do it.

But thanks for your reply!