久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

    <tfoot id='vU2v4'></tfoot>
      <legend id='vU2v4'><style id='vU2v4'><dir id='vU2v4'><q id='vU2v4'></q></dir></style></legend>

        • <bdo id='vU2v4'></bdo><ul id='vU2v4'></ul>

        <small id='vU2v4'></small><noframes id='vU2v4'>

        <i id='vU2v4'><tr id='vU2v4'><dt id='vU2v4'><q id='vU2v4'><span id='vU2v4'><b id='vU2v4'><form id='vU2v4'><ins id='vU2v4'></ins><ul id='vU2v4'></ul><sub id='vU2v4'></sub></form><legend id='vU2v4'></legend><bdo id='vU2v4'><pre id='vU2v4'><center id='vU2v4'></center></pre></bdo></b><th id='vU2v4'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='vU2v4'><tfoot id='vU2v4'></tfoot><dl id='vU2v4'><fieldset id='vU2v4'></fieldset></dl></div>
      1. SpringBoot - BeanDefinitionOverrideException:無效的bean定義

        SpringBoot - BeanDefinitionOverrideException: Invalid bean definition(SpringBoot - BeanDefinitionOverrideException:無效的bean定義)

        <legend id='BqIYj'><style id='BqIYj'><dir id='BqIYj'><q id='BqIYj'></q></dir></style></legend>

            <tbody id='BqIYj'></tbody>

          <i id='BqIYj'><tr id='BqIYj'><dt id='BqIYj'><q id='BqIYj'><span id='BqIYj'><b id='BqIYj'><form id='BqIYj'><ins id='BqIYj'></ins><ul id='BqIYj'></ul><sub id='BqIYj'></sub></form><legend id='BqIYj'></legend><bdo id='BqIYj'><pre id='BqIYj'><center id='BqIYj'></center></pre></bdo></b><th id='BqIYj'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='BqIYj'><tfoot id='BqIYj'></tfoot><dl id='BqIYj'><fieldset id='BqIYj'></fieldset></dl></div>
            <tfoot id='BqIYj'></tfoot>
              <bdo id='BqIYj'></bdo><ul id='BqIYj'></ul>

              <small id='BqIYj'></small><noframes id='BqIYj'>

                  本文介紹了SpringBoot - BeanDefinitionOverrideException:無效的bean定義的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我正在嘗試使用 Spring Boot 在本地設置 DynamoDB.最初,我使設置正常工作,并且能夠通過存儲庫寫入/保存到 DynamoDB.從那時起,我添加了更多類來構建我的應用程序.現在,當我嘗試啟動我的應用程序時,出現以下異常:

                  I am trying to setup DynamoDB locally with Spring Boot. Initially I got the setup working and was able to write/save to DynamoDB via a repository. From that point I added more classes to build my application. Now when I try to start my application, I get the following exception:

                  org.springframework.beans.factory.support.BeanDefinitionOverrideException:無效的 bean 定義,名稱為 'agentRepository' 在 null 中定義:無法注冊 bean 定義 [根 bean:類 [org.socialsignin.spring.data.dynamodb.repository.support.DynamoDBRepositoryFactoryBean];范圍=;摘要=假;懶惰初始化=假;自動線模式=0;依賴檢查=0;自動接線候選=真;主要=假;工廠BeanName=空;工廠方法名=空;初始化方法名=空;bean 'agentRepository' 的 destroyMethodName=null]:已經有 [根 bean:類 [org.socialsignin.spring.data.dynamodb.repository.support.DynamoDBRepositoryFactoryBean];范圍=;摘要=假;懶惰初始化=假;自動線模式=0;依賴檢查=0;自動接線候選=真;主要=假;工廠BeanName=空;工廠方法名=空;初始化方法名=空;destroyMethodName=null] 綁定.

                  我已經廣泛搜索了 SO 和互聯網,但沒有任何有用的解決方案.錯誤消息也具有誤導性.

                  I have searched SO and internet extensively but there were no any useful solution to this. The error message is misleading as well.

                  我的項目具有以下層次結構

                  My project is of the following hierarchy

                  ai.test.as
                    - as
                        - agent
                            - business
                            - intent
                            - exception
                            - Agent.java
                            - AgentDTO.java
                            - AgentRespository.java
                            - AgentController.java
                            - AgentService.java
                            - AgentServiceImpl.java
                    - config
                       - DynamoDBConfig.java
                  

                  DynamoDBConfig.java

                  DynamoDBConfig.java

                  package ai.test.as.config;
                  
                  import ai.test.as.agent.AgentRepository;
                  import ai.test.as.agent.intent.template.TemplateRepository;
                  import com.amazonaws.auth.AWSCredentials;
                  import com.amazonaws.auth.BasicAWSCredentials;
                  import com.amazonaws.services.dynamodbv2.AmazonDynamoDB;
                  import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient;
                  import org.socialsignin.spring.data.dynamodb.repository.config.EnableDynamoDBRepositories;
                  import org.springframework.beans.factory.annotation.Value;
                  import org.springframework.context.annotation.Bean;
                  import org.springframework.context.annotation.Configuration;
                  
                  @Configuration
                  @EnableDynamoDBRepositories(basePackageClasses = {AgentRepository.class})
                  public class DynamoDBConfig
                  {
                      @Value("${aws.dynamodb.endpoint}")
                      private String dynamoDBEndpoint;
                  
                      @Value("${aws.auth.accesskey}")
                      private String awsAccessKey;
                  
                      @Value("${aws.auth.secretkey}")
                      private String awsSecretKey;
                  
                      @Bean
                      public AmazonDynamoDB amazonDynamoDB()
                      {
                          AmazonDynamoDB dynamoDB = new AmazonDynamoDBClient(getAwsCredentials());
                          dynamoDB.setEndpoint(dynamoDBEndpoint);
                  
                          return dynamoDB;
                      }
                  
                      @Bean
                      public AWSCredentials getAwsCredentials()
                      {
                          return new BasicAWSCredentials(awsAccessKey, awsSecretKey);
                      }
                  }
                  

                  AgentRepository.java

                  AgentRepository.java

                  package ai.test.as.agent;
                  
                  import ai.test.as.agent.Agent;
                  import org.socialsignin.spring.data.dynamodb.repository.EnableScan;
                  import org.springframework.data.repository.CrudRepository;
                  
                  @EnableScan
                  public interface AgentRepository extends CrudRepository<Agent, String>
                  {
                  }
                  

                  AgentController.java(使用 AgentRepository 的地方)

                  AgentController.java (Where AgentRepository is used)

                  @RestController
                  @RequestMapping(value = "/v1/agents")
                  public class AgentController
                  {
                      @Autowired
                      private AgentRepository agentRepository;
                  
                      @RequestMapping(value = "/test", method = RequestMethod.POST)
                      public void test()
                      {
                          Agent agent = new Agent();
                          agent.setAgentNumber("123456");
                          agent.setId(1);
                  
                          agentRepository.save(agent);
                      }
                  }
                  

                  Spring 建議如下:<代碼>>在 null 中定義的 bean 'agentRepository' 無法注冊.已在 null 中定義了具有該名稱的 bean,并且已禁用覆蓋.

                  Spring suggests the following: > The bean 'agentRepository', defined in null, could not be registered. A bean with that name has already been defined in null and overriding is disabled.

                  null 在這里是什么意思?是因為我的應用程序配置有問題嗎?還有怎么可能已經注冊了?

                  What does null mean here? Is it because something wrong in my application config? Also how is it possible that it is already registered?

                  請給我一些指示,因為我對接下來的步驟感到很困惑.

                  Please give me some pointers because I so confused about my next steps.

                  推薦答案

                  從 Spring Boot 2.1 開始必須啟用 Bean 覆蓋,

                  Bean overriding has to be enabled since Spring Boot 2.1,

                  https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.1-Release-Notes

                  Bean 覆蓋

                  默認情況下禁用 Bean 覆蓋以防止意外覆蓋 bean.如果您依賴覆蓋,則需要將 spring.main.allow-bean-definition-overriding 設置為 true.

                  Bean overriding has been disabled by default to prevent a bean being accidentally overridden. If you are relying on overriding, you will need to set spring.main.allow-bean-definition-overriding to true.

                  設置

                  spring.main.allow-bean-definition-overriding=true
                  

                  或yml,

                  spring:
                     main:
                       allow-bean-definition-overriding: true
                  

                  再次啟用覆蓋.

                  編輯,

                  Bean Overriding 是基于 bean 的名稱而不是它的類型.例如

                  Bean Overriding is based of the name of the bean not its type. e.g.

                  @Bean
                  public ClassA class(){
                     return new ClassA();
                  }
                  
                  @Bean
                  public ClassB class(){
                     return new ClassB();
                  }
                  

                  會在>中造成這個錯誤2.1,默認情況下bean名稱取自方法名稱.重命名方法或將 name 屬性添加到 Bean 注釋將是有效的修復方法.

                  Will cause this error in > 2.1, by default bean names are taken from the method name. Renaming the method or adding the name attribute to the Bean annotation will be a valid fix.

                  這篇關于SpringBoot - BeanDefinitionOverrideException:無效的bean定義的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  How can I detect integer overflow on 32 bits int?(如何檢測 32 位 int 上的整數溢出?)
                  Local variables before return statements, does it matter?(return 語句之前的局部變量,這有關系嗎?)
                  How to convert Integer to int?(如何將整數轉換為整數?)
                  How do I create an int array with randomly shuffled numbers in a given range(如何在給定范圍內創建一個隨機打亂數字的 int 數組)
                  Inconsistent behavior on java#39;s ==(java的行為不一致==)
                  Why is Java able to store 0xff000000 as an int?(為什么 Java 能夠將 0xff000000 存儲為 int?)

                      <small id='LA2kp'></small><noframes id='LA2kp'>

                      <legend id='LA2kp'><style id='LA2kp'><dir id='LA2kp'><q id='LA2kp'></q></dir></style></legend>
                      <tfoot id='LA2kp'></tfoot>

                          <tbody id='LA2kp'></tbody>

                        • <bdo id='LA2kp'></bdo><ul id='LA2kp'></ul>

                          • <i id='LA2kp'><tr id='LA2kp'><dt id='LA2kp'><q id='LA2kp'><span id='LA2kp'><b id='LA2kp'><form id='LA2kp'><ins id='LA2kp'></ins><ul id='LA2kp'></ul><sub id='LA2kp'></sub></form><legend id='LA2kp'></legend><bdo id='LA2kp'><pre id='LA2kp'><center id='LA2kp'></center></pre></bdo></b><th id='LA2kp'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='LA2kp'><tfoot id='LA2kp'></tfoot><dl id='LA2kp'><fieldset id='LA2kp'></fieldset></dl></div>
                          • 主站蜘蛛池模板: 国产精品免费看 | 国产精品中文字幕一区二区三区 | 91精品国产综合久久久久久丝袜 | 国产99免费视频 | 天天爱爱网 | 中文字幕乱码一区二区三区 | 99视频精品| 欧美狠狠操 | 亚洲高清视频在线观看 | 热99精品视频| 影音先锋中文字幕在线观看 | 色橹橹欧美在线观看视频高清 | 成人精品福利 | 天天久久| 日韩av资源站 | 亚洲天天干 | 99热免费在线 | 中文字幕精品一区二区三区精品 | 日韩精品成人网 | 天天av天天好逼 | 久久久一区二区三区四区 | 正在播放国产精品 | 成人av播放 | www.精品国产 | 国产一级免费在线观看 | 黄色片网站国产 | 久久88| 中文在线一区二区 | 美女福利网站 | 国产黄色一级片 | 91成人免费电影 | 久久久久久久久国产成人免费 | 日韩在线观看一区 | 国产精品久久久久久久久久软件 | caoporn国产精品免费公开 | 亚洲精品一区二区三区中文字幕 | 日韩最新网站 | 九色在线观看 | 日本黄色片免费在线观看 | 国产区在线视频 | 成人午夜激情 |