Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2008/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 在abcService类中获取错误(字段xyzRepository(扩展JPA存储库)需要一个找不到的xyzRepository bean_Java - Fatal编程技术网

Java 在abcService类中获取错误(字段xyzRepository(扩展JPA存储库)需要一个找不到的xyzRepository bean

Java 在abcService类中获取错误(字段xyzRepository(扩展JPA存储库)需要一个找不到的xyzRepository bean,java,Java,sipRepository.java import sip.sipDemo.model.mysql.SipEntity; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Component; import org.springframework.stereotype.Repository; @Co

sipRepository.java

    import sip.sipDemo.model.mysql.SipEntity;
    import org.springframework.data.jpa.repository.JpaRepository;
    import org.springframework.stereotype.Component;
    import org.springframework.stereotype.Repository;
    
    @Component
    @Repository
    public interface SipRepository extends JpaRepository<SipEntity,Integer>{
    
    }
SipController.java

    package sip.sipDemo.Controller;
    import sip.sipDemo.Service.SipService;
    import sip.sipDemo.model.mysql.SipEntity;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.stereotype.Controller;
    import org.springframework.web.bind.annotation.GetMapping;
    import org.springframework.web.bind.annotation.PathVariable;
    import org.springframework.web.bind.annotation.ResponseBody;
    import java.util.List;
    import java.util.Optional;
    
    @Controller
    public class SipController {
    
         @Autowired
         private SipService sipservice;
    
    
        @ResponseBody
        @GetMapping(value="/")
        public String home()
        {
            return "Hello";
        }
    
        @ResponseBody
        @GetMapping(value = "/getAllEntities")
        public List<SipEntity> getAllEntities()
        {
             List<SipEntity> newList = sipservice.getAllEntities();
    
             return newList;
        }
    }
错误消息如下所示

: APPLICATION FAILED TO START

    ***************************
    
    Description:
    
    Field sipRepository in sip.sipDemo.Service.SipService required a bean of type 'sip.sipDemo.repository.mysql.SipRepository' that could not be found.
    
    The injection point has the following annotations:
        - @org.springframework.beans.factory.annotation.Autowired(required=true)
    
    
    Action:
    
    Consider defining a bean of type 'sip.sipDemo.repository.mysql.SipRepository' in your configuration.
    
    
    > Task :SipDemoApplication.main() FAILED
应用程序属性

    spring.datasource.url= jdbc:mysql://localhost:3306/sys?autoReconnect=true&zeroDateTimeBehavior=convertToNull
    spring.datasource.username=root
    spring.datasource.password=******** (actual password)
    spring.jpa.hibernate.ddl-auto=update
    spring.jpa.properties.org.hibernate.envers.audit_table_suffix=_AUDIT_LOG
    spring.jpa.show-sql=true
    spring.jpa.properties.hibernate.format_sql=true
    spring.jpa.database-platform=org.hibernate.dialect.MySQL5InnoDBDialect
  • 我用过mysql数据库
  • 主类位于最外层,包结构良好
  • 如果我在sipService中删除sipRepository对象的@Autowire,sipRepository的控制器端点将不工作,但其余的正常工作
  • 请提供可能的错误来源
  •     package sip.sipDemo;
        
        import org.springframework.boot.SpringApplication;
        import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
        import org.springframework.boot.autoconfigure.SpringBootApplication;
        import org.springframework.context.annotation.ComponentScan;
        import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
        
        @EnableAutoConfiguration
        @ComponentScan(basePackages = {"sip.sipDemo"})
        @SpringBootApplication
        public class SipDemoApplication {
        
            public static void main(String[] args) {
                SpringApplication.run(SipDemoApplication.class, args);
                
            }
        
        }
    
    : APPLICATION FAILED TO START
    
        ***************************
        
        Description:
        
        Field sipRepository in sip.sipDemo.Service.SipService required a bean of type 'sip.sipDemo.repository.mysql.SipRepository' that could not be found.
        
        The injection point has the following annotations:
            - @org.springframework.beans.factory.annotation.Autowired(required=true)
        
        
        Action:
        
        Consider defining a bean of type 'sip.sipDemo.repository.mysql.SipRepository' in your configuration.
        
        
        > Task :SipDemoApplication.main() FAILED
    
        spring.datasource.url= jdbc:mysql://localhost:3306/sys?autoReconnect=true&zeroDateTimeBehavior=convertToNull
        spring.datasource.username=root
        spring.datasource.password=******** (actual password)
        spring.jpa.hibernate.ddl-auto=update
        spring.jpa.properties.org.hibernate.envers.audit_table_suffix=_AUDIT_LOG
        spring.jpa.show-sql=true
        spring.jpa.properties.hibernate.format_sql=true
        spring.jpa.database-platform=org.hibernate.dialect.MySQL5InnoDBDialect
    
       │   │               └── sipDemo
        │   │                   ├── Controller
        │   │                   │   └── SipController.java
        │   │                   ├── model
        │   │                   │   └── mysql
        │   │                   │       └── SipEntity.java
        │   │                   ├── repository
        │   │                   │   └── mysql
        │   │                   │       └── SipRepository.java
        │   │                   ├── Service
        │   │                   │   └── SipService.java
        │   │                   └── SipDemoApplication.java
        │   └── resources
        │       ├── application.properties
        │       ├── static
        │       └── templates