【问题标题】:Heroku compilation failure. Illigal characterHeroku 编译失败。非法字符
【发布时间】:2017-01-06 13:00:29
【问题描述】:

这是我第一次尝试向 heroku 提交任何应用程序。我在关注this tutorial. 我已经安装了 Spring CLI。我对 git 进行了更改并使用了命令 heroku create,它运行良好,但是使用时:git push heroku master 在编译过程中出现错误,如下所示:

[错误] 编译错误: [错误]/tmp/build_c2569e1c27c1c307e42528c66e67c016/src/main/java/com/example/configuration/SecurityConfig.java:[123,125] 表达式的非法开头
[错误]/tmp/build_c2569e1c27c1c307e42528c66e67c016/src/main/java/com/example/configuration/SecurityConfig.java:[123,126] ';'预期 [错误] 未能执行目标 org.apache.maven.plugins:maven-compiler-plugin:3.1:compile 项目演示中的(默认编译):编译失败:编译 失败:
[错误]/tmp/build_c2569e1c27c1c307e42528c66e67c016/src/main/java/com/example/configuration/SecurityConfig.java:[123,125] 非法的表达式开头 [错误]/tmp/build_c2569e1c27c1c307e42528c66e67c016/src/main/java/com/example/configuration/SecurityConfig.java:[123,126] ';'预计

项目在本地机器上编译和启动非常好,有人知道可能出了什么问题吗?

这里是 SecuityConfig 类

@Configuration
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {

    private static final String HMAC_ALGO = "HmacSHA256";

    @Autowired
    @Qualifier("myUserDetailService")
    UserDetailsService userDetailsService;

    @Autowired
    ObjectMapper objectMapper;

    @Override
    protected void configure(HttpSecurity http) throws Exception {

        http.httpBasic();
        http.addFilterAfter(new CsrfTokenToCookieFilter(), CsrfFilter.class);
        http.csrf().csrfTokenRepository(csrfTokenRepository());
        http.userDetailsService(userDetailsService);
        http
                .authorizeRequests()
                .antMatchers(HttpMethod.GET, "/admin/**").hasRole(Authorities.SUPER_ADMIN_VAL)
                .antMatchers(HttpMethod.GET, "/admin").hasAnyRole(Authorities.ROLE_ADMIN_VAL, Authorities.SUPER_ADMIN_VAL)
                .antMatchers(HttpMethod.POST, "/admin").hasRole(Authorities.SUPER_ADMIN_VAL)
                .antMatchers(HttpMethod.PUT, "/admin").hasRole(Authorities.SUPER_ADMIN_VAL)
                .antMatchers(HttpMethod.DELETE, "/admin").hasRole(Authorities.SUPER_ADMIN_VAL)
                .antMatchers(HttpMethod.POST, "/order", "/client").permitAll()
                .antMatchers(HttpMethod.GET, "/").hasRole(Authorities.ROLE_ADMIN_VAL)
                .regexMatchers(HttpMethod.POST, "/").hasRole(Authorities.ROLE_ADMIN_VAL)
                .regexMatchers(HttpMethod.DELETE, "/").hasRole(Authorities.ROLE_ADMIN_VAL)
                .regexMatchers(HttpMethod.PUT, "/").hasRole(Authorities.ROLE_ADMIN_VAL)
                .antMatchers(HttpMethod.GET, "/").permitAll();
    }

    private CsrfTokenRepository csrfTokenRepository() {
        HttpSessionCsrfTokenRepository repository = new HttpSessionCsrfTokenRepository();
        repository.setHeaderName("X-XSRF-TOKEN");
        return repository;
    }
}

最奇怪的是,当实际类只包含 66 行时,错误指向 123 维行

【问题讨论】:

    标签: maven heroku spring-boot


    【解决方案1】:

    问题是,我完全忘记向主早午餐提出拉取请求。我一开始就没有设法将错误的代码提交给主早午餐。现在一切都已修复并正常工作。

    【讨论】:

      猜你喜欢
      • 2012-11-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-11-15
      • 2021-11-12
      • 2014-06-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多