简体   繁体   English

将Spring Boot War部署到Liberty无法正常工作

[英]Deploying Spring Boot War to Liberty not working

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. 我有一个简单的Spring Boot应用程序,当我在Eclipse中使用我的Liberty服务器运行runnig时,我可以很好地运行,问题是当我尝试对war文件进行构建(使用maven)并将War添加到同一服务器并尝试要运行它,服务器可以正常启动,但是在击中服务器URL后,它会显示Spring安全性登录名/密码弹出窗口,但是在我的应用程序中,我已经配置了登录名和一些示例端点,但是服务器找不到它们,看起来好像没有Spring从WAR运行时找到配置,当在同一Liberty服务器中通过运行方式运行时,该应用程序正常运行。

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 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();




    }

我希望您在WebSecurityConfig类上添加了@EnableWebSecurity批注。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM