0

I have a simple Spring Boot application that i can run fine when runnig using my Liberty server in Eclipse, the problem is that when i try to do a build (with maven) to a war file and adding that War to the same server and trying to run it, the server starts fine but after hitting the server URL it displays the Spring security login/password popup, but in my application i have configured a login and a few example endpoints but the server cant find them, it looks like no Spring configuration is found when running from the WAR, the application works without errors when running via Run As in the same Liberty server.

Here's my main class:

@SpringBootApplication
public class ServletInitializer extends SpringBootServletInitializer {

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(ServletInitializer.class);
    }

    public static void main(String[] args) throws Exception {
        SpringApplication.run(ServletInitializer.class, args);
    }

}

Pom.xml

<groupId>com.example</groupId>
    <artifactId>demo</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>war</packaging>

Part of my Security config class

@Configuration
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {

    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http
            .csrf().disable()
            .authorizeRequests()
            .antMatchers("/resources/**").permitAll()
                .anyRequest().fullyAuthenticated()
                .and()
            .formLogin()
            .loginPage("/login")
            .permitAll();




    }
Mauro M
  • 669
  • 1
  • 8
  • 25

1 Answers1

0

I hope you have added @EnableWebSecurity annotation on your WebSecurityConfig class.