Java 从Zuul API网关访问REST端点时出现404错误

Java 从Zuul API网关访问REST端点时出现404错误,java,angularjs,spring,microservices,netflix-zuul,Java,Angularjs,Spring,Microservices,Netflix Zuul,有人能帮我吗?我已经绞尽脑汁想了三天了,但都没法实现 API网关应用程序和安全配置以及资源服务器: @SpringBootApplication @EnableZuulProxy @EnableDiscoveryClient public class Application { /** * This is where the application is bootstrapped. * * @param arguments the command line

有人能帮我吗?我已经绞尽脑汁想了三天了,但都没法实现

API网关应用程序和安全配置以及资源服务器:

@SpringBootApplication
@EnableZuulProxy
@EnableDiscoveryClient
public class Application {

    /**
     * This is where the application is bootstrapped.
     *
     * @param arguments the command line arguments
     */
    public static void main(String... arguments) {
        SpringApplication.run(Application.class, arguments);
    }

}

@Configuration
@EnableWebSecurity
@EnableOAuth2Client
@Order(6)
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http
            .headers().disable()
            .csrf().disable()
            .authorizeRequests()
                .antMatchers("/**").permitAll()            
                .antMatchers(HttpMethod.OPTIONS, "/**").permitAll()
                .antMatchers("/", "/webjars/**").permitAll()
                .antMatchers("/xuath/login**", "/security/oauth/**", "/user/oauth/**").permitAll()
                .antMatchers("/user/api/account**", "/user/api/account/**").permitAll()
                .anyRequest().authenticated()
                .and()
            .exceptionHandling()
                .authenticationEntryPoint(new LoginUrlAuthenticationEntryPoint("/"))
                .and()
            .logout()
                .logoutUrl("/xuath/logout")
                .logoutSuccessUrl("/").permitAll()
                .and()
            .addFilterBefore(ssoFilter(), BasicAuthenticationFilter.class);
    }
}

@Configuration
@EnableResourceServer
public class ResourceServerConfiguration extends ResourceServerConfigurerAdapter {

    @Override
    public void configure(HttpSecurity http) throws Exception {
        http.antMatcher("/api/**").authorizeRequests()
                .anyRequest().authenticated()
                .and()
                .antMatcher("/admin/**").authorizeRequests()
                .anyRequest().hasRole("ADMIN");
    }

}
yml zuul路线示例:

zuul:
    routes:
        app-security:
            path: /security/**            
            retryable: true
            sensitive-headers:
            strip-prefix: false
以下是应用程序安全应用程序和安全配置以及资源服务器配置:

@SpringBootApplication
@EnableJpaAuditing
@EnableDiscoveryClient
public class Application {

    /**
     * This is used for method level validation.
     *
     * @return the {@link MethodValidationPostProcessor}
     */
    @Bean
    public MethodValidationPostProcessor methodValidationPostProcessor() {
        return new MethodValidationPostProcessor();
    }

    /**
     * This is where the application is bootstrapped.
     *
     * @param arguments the command line arguments
     */
    public static void main(String... arguments) {
        SpringApplication.run(Application.class, arguments);
    }

}

@Configuration
@EnableWebSecurity
@EnableOAuth2Client
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {

    /**
     * {@inheritDoc }
     */
    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http.csrf().disable()
            .authorizeRequests()
                .antMatchers("/oauth/**").permitAll()
                .anyRequest().authenticated()
                .and()
            .httpBasic();
    }
}

@Configuration
@EnableResourceServer
public class ResourceServerConfiguration extends ResourceServerConfigurerAdapter {

    /**
     * {@inheritDoc }
     */
    @Override
    public void configure(HttpSecurity http) throws Exception {
        http.antMatcher("/api/**").authorizeRequests()
            .anyRequest().authenticated();
    }

}
当我在成功验证后尝试从浏览器请求以下url localhost:80/security/oauth/me时,它将返回当前登录用户的json响应。但当我尝试在AngularJS应用程序中使用
$http.get()
时,它返回404 not found。为什么?

下面是我的AngularJS控制器:

duyogApp.controller 'loginCtrl', ['$scope', ($scope) ->

    $http.get('http://localhost:80/security/oauth/me').then (d) ->
            console.log d.data
]   

如果在浏览器上启用开发人员工具,则可以看到http get使用的url。你能确认它使用的是正确的url吗?@jay,是的,它是相同的url。你能发布你的angularjs代码吗?也给它贴上标签?