Ok, this is my first attempt to app on heroku. I followed this tutorial, I have installed Spring CLI and Heroku CLI, an error appears when I try to close an application with approximately the same stack trace:
[ERROR] COMPILATION ERROR: [ERROR] /tmp/build_c2569e1c27c1c307e42528c66e67c016/src/main/java/com/example/configuration/SecurityConfig.java: [123,125] /com/example/configuration/SecurityConfig.java:[123,126] ';' expected [ERROR] Failed to execute goal org.apache.maven.plugins: maven-compiler-plugin: 3.1: compile (default-compile) illegal / java / com / example / configuration / SecurityConfig.java: [123,125] ' expected
The application works fine on the local machine. Here is my pom.xml
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.example</groupId> <artifactId>demo</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>jar</packaging> <name>solid_fuel_inc</name> <description>Web site for distribution of solid fuel</description> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.3.6.RELEASE</version> <relativePath/> <!-- lookup parent from repository --> </parent> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <java.version>1.8</java.version> </properties> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-cache</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-jpa</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-mail</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-security</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-validation</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.aspectj</groupId> <artifactId>aspectjrt</artifactId> <version>1.8.6</version> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <scope>runtime</scope> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>commons-codec</groupId> <artifactId>commons-codec</artifactId> <version>1.10</version> </dependency> <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-test</artifactId> <version>4.0.0.RELEASE</version> <scope>test</scope> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <version>1.4.0.RELEASE</version> <optional>true</optional> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> //при сборке этот плагин копирует статические файлы в директорию static как того требует spring boot <plugin> <artifactId>maven-resources-plugin</artifactId> <version>2.6</version> <executions> <execution> <id>copy-resources</id> <phase>validate</phase> <goals> <goal>copy-resources</goal> </goals> <configuration> <outputDirectory>${basedir}/target/classes/static</outputDirectory> <resources> <resource> <directory>src/main/webapp</directory> <filtering>true</filtering> </resource> </resources> </configuration> </execution> </executions> </plugin> </plugins> </build> </project> The file on which SpringSecurityConfig.java swear.
@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; } }
SecurityConfig.javato the question - Komdosh