有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

@Configuration注释的java问题。Singelton bean创建得太早

我对这种类型的编程相当陌生。事实上,这是我第一个使用Spring设置的Java项目。对于我的web应用程序,它在本地Postman和h2控制台上提供了良好的结果,我创建了一个JAR文件。现在,在执行这个jar文件时,除了控制台抱怨的其他问题消息外:

Cannot enhance @Configuration bean definition 
        'org.axonframework.springboot.autoconfig.EventProcessingAutoConfiguration' 
         since its
        singleton instance has been created too early. The typical cause is a non- 
        static @Bean method with a BeanDefinitionRegistryPostProcessor return 
        type: 
        Consider declaring such methods as 'static'.
import org.springframework.context.annotation.Configuration;
import org.springframework.messaging.simp.config.MessageBrokerRegistry;
import org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker;
import org.springframework.web.socket.config.annotation.StompEndpointRegistry;
import org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurer;

@Configuration
@EnableWebSocketMessageBroker
public class WebsocketConfig implements WebSocketMessageBrokerConfigurer {

    @Override
    public void configureMessageBroker(MessageBrokerRegistry config){
        config.enableSimpleBroker("/topic");
        //config.setApplicationDestinationPrefixes("/app");
    }

    @Override
    public void registerStompEndpoints(StompEndpointRegistry registry) {
        registry.addEndpoint("/ws")
                .setAllowedOrigins("*");
    }
    }

我使用此注释的唯一类是上面的websocket配置类。 但我不知道“静态”如何解决这个问题,更不用说理解了。 我已经在互联网上查找了这个特定的问题,并观看了关于Springbean定义的教程。我仍然不确定我是否能在这里确定这个问题。如果您需要我的类中的更多代码,请告诉我


共 (0) 个答案