第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

'com.example.demo.GirlRepository' that could not be found.GirlRepository(已解決)

Description:

Field girlRepository in com.example.demo.GirlController required a bean of type 'com.example.demo.GirlRepository' that could not be found.


Action:

Consider defining a bean of type 'com.example.demo.GirlRepository' in your configuration.


GirlRepository和GirlApplication都在同一個(gè)包下面的

http://img1.sycdn.imooc.com//592d260b00016b0204400258.jpg

已解決

正在回答

10 回答

https://img1.sycdn.imooc.com//5b3a31d800010b4e06260172.jpg大兄弟,幫我看下,我用的是這個(gè)jpa但是為什么還是注入失敗呢?

0 回復(fù) 有任何疑惑可以回復(fù)我~
#1

深藍(lán)d

我和你一樣,你知道怎么解決了嗎
2019-05-17 回復(fù) 有任何疑惑可以回復(fù)我~

還有一種可能,少寫(xiě)了

public?class?GirlService?{

上面的注解@Service

0 回復(fù) 有任何疑惑可以回復(fù)我~
  1. 你把運(yùn)行的application類(lèi)放到最基本的包里,比如:com.imooc 這個(gè)包下!

0 回復(fù) 有任何疑惑可以回復(fù)我~

java.lang.IllegalStateException: ApplicationEventMulticaster not initialized - call 'refresh' before multicasting events via the context: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@13c10b87: startup date [Mon Aug 21 22:25:23 CST 2017]; root of context hierarchy

at org.springframework.context.support.AbstractApplicationContext.getApplicationEventMulticaster(AbstractApplicationContext.java:414) [spring-context-4.3.10.RELEASE.jar:4.3.10.RELEASE]

at org.springframework.context.support.ApplicationListenerDetector.postProcessBeforeDestruction(ApplicationListenerDetector.java:97) ~[spring-context-4.3.10.RELEASE.jar:4.3.10.RELEASE]

at org.springframework.beans.factory.support.DisposableBeanAdapter.destroy(DisposableBeanAdapter.java:253) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]

at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroyBean(DefaultSingletonBeanRegistry.java:578) [spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]

at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingleton(DefaultSingletonBeanRegistry.java:554) [spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]

at org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingleton(DefaultListableBeanFactory.java:961) [spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]

at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingletons(DefaultSingletonBeanRegistry.java:523) [spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]

at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.destroySingletons(FactoryBeanRegistrySupport.java:230) [spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]

at org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingletons(DefaultListableBeanFactory.java:968) [spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]

at org.springframework.context.support.AbstractApplicationContext.destroyBeans(AbstractApplicationContext.java:1030) [spring-context-4.3.10.RELEASE.jar:4.3.10.RELEASE]

at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:556) [spring-context-4.3.10.RELEASE.jar:4.3.10.RELEASE]

at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) [spring-boot-1.5.6.RELEASE.jar:1.5.6.RELEASE]

at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693) [spring-boot-1.5.6.RELEASE.jar:1.5.6.RELEASE]

at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360) [spring-boot-1.5.6.RELEASE.jar:1.5.6.RELEASE]

at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) [spring-boot-1.5.6.RELEASE.jar:1.5.6.RELEASE]

at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118) [spring-boot-1.5.6.RELEASE.jar:1.5.6.RELEASE]

at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107) [spring-boot-1.5.6.RELEASE.jar:1.5.6.RELEASE]

at com.example.demo.DemoApplication.main(DemoApplication.java:10) [classes/:na]


2017-08-21 22:25:24.528 ERROR 46202 --- [ ? ? ? ? ? main] o.s.b.f.s.DefaultListableBeanFactory ? ? : Destroy method on bean with name 'org.springframework.boot.autoconfigure.internalCachingMetadataReaderFactory' threw an exception


java.lang.IllegalStateException: ApplicationEventMulticaster not initialized - call 'refresh' before multicasting events via the context: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@13c10b87: startup date [Mon Aug 21 22:25:23 CST 2017]; root of context hierarchy

at org.springframework.context.support.AbstractApplicationContext.getApplicationEventMulticaster(AbstractApplicationContext.java:414) [spring-context-4.3.10.RELEASE.jar:4.3.10.RELEASE]

at org.springframework.context.support.ApplicationListenerDetector.postProcessBeforeDestruction(ApplicationListenerDetector.java:97) ~[spring-context-4.3.10.RELEASE.jar:4.3.10.RELEASE]

at org.springframework.beans.factory.support.DisposableBeanAdapter.destroy(DisposableBeanAdapter.java:253) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]

at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroyBean(DefaultSingletonBeanRegistry.java:578) [spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]

at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingleton(DefaultSingletonBeanRegistry.java:554) [spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]

at org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingleton(DefaultListableBeanFactory.java:961) [spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]

at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingletons(DefaultSingletonBeanRegistry.java:523) [spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]

at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.destroySingletons(FactoryBeanRegistrySupport.java:230) [spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]

at org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingletons(DefaultListableBeanFactory.java:968) [spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]

at org.springframework.context.support.AbstractApplicationContext.destroyBeans(AbstractApplicationContext.java:1030) [spring-context-4.3.10.RELEASE.jar:4.3.10.RELEASE]

at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:556) [spring-context-4.3.10.RELEASE.jar:4.3.10.RELEASE]

at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) [spring-boot-1.5.6.RELEASE.jar:1.5.6.RELEASE]

at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693) [spring-boot-1.5.6.RELEASE.jar:1.5.6.RELEASE]

at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360) [spring-boot-1.5.6.RELEASE.jar:1.5.6.RELEASE]

at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) [spring-boot-1.5.6.RELEASE.jar:1.5.6.RELEASE]

at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118) [spring-boot-1.5.6.RELEASE.jar:1.5.6.RELEASE]

at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107) [spring-boot-1.5.6.RELEASE.jar:1.5.6.RELEASE]

at com.example.demo.DemoApplication.main(DemoApplication.java:10) [classes/:na]

我包這個(gè)錯(cuò)不知道是啥問(wèn)題

0 回復(fù) 有任何疑惑可以回復(fù)我~

這個(gè)問(wèn)題我也存在 但是把所有類(lèi)放到一個(gè)包下面就好了


0 回復(fù) 有任何疑惑可以回復(fù)我~
#1

qq_Weakmindedyo_0

@SpringBootApplication 這個(gè)注解的類(lèi)要放在最外圍的包里,一遍能管理到其他 controller
2017-09-22 回復(fù) 有任何疑惑可以回復(fù)我~
#2

慕絲6569890 回復(fù) qq_Weakmindedyo_0

可以留下聯(lián)系方式嗎
2017-09-26 回復(fù) 有任何疑惑可以回復(fù)我~

復(fù)制的時(shí)候 多了這個(gè)<scope>test</scope>在 pom中

0 回復(fù) 有任何疑惑可以回復(fù)我~

我跟你的錯(cuò)誤一樣,但是用了import org.springframework.data.jpa.repository.JpaRepository;還是沒(méi)解決/(ㄒoㄒ)/~~還可能是什么原因嗎

0 回復(fù) 有任何疑惑可以回復(fù)我~
#1

未卜先知 提問(wèn)者

jap在maven中注意要用spring-boot start那個(gè),不要用spring data下的 我是在寫(xiě)代碼的時(shí)候直接用工具導(dǎo)入的,結(jié)果工具導(dǎo)入的依賴(lài)是spring data的jpa不是spring boot的jpa
2017-06-14 回復(fù) 有任何疑惑可以回復(fù)我~
#2

glwindy 回復(fù) 未卜先知 提問(wèn)者

灰常感謝
2017-06-15 回復(fù) 有任何疑惑可以回復(fù)我~
#3

qq_別人家的小明_0

那個(gè),我還是沒(méi)搞懂,我導(dǎo)入的是 spring-boot-starter-data-jpa,結(jié)果還是報(bào)的這個(gè)錯(cuò)誤。。。
2018-01-04 回復(fù) 有任何疑惑可以回復(fù)我~

是的,是要注入GirlRepository,和GirlProperties沒(méi)關(guān)系,要不你對(duì)比下我的,我能執(zhí)行?;蛘吣愕拇aidea有提示錯(cuò)誤嗎?

package com.girl.repository;

import com.girl.domain.Girl;
import org.springframework.data.jpa.repository.JpaRepository;

import java.util.List;

/**
* Created by zouzhi on 2017/5/30.
*/
public interface GirlRepository extends JpaRepository<Girl,Integer> {
? ?public List<Girl> findByAge(Integer age);
}



package com.girl.controller;

import com.girl.domain.Girl;
import com.girl.repository.GirlRepository;
import com.girl.service.GirlService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
* Created by zouzhi on 2017/5/30.
*/
@RestController
public class GirlController {


? ?private final static Logger logger = LoggerFactory.getLogger(GirlController.class);

? ?@Autowired
? ?private GirlRepository girlRepository;

? ?@Autowired
? ?private GirlService girlService;

? ?@GetMapping(value = "/girls")
? ?public List<Girl> girlList(){
? ? ? ?//System.out.println("girlList()");
? ? ? ?logger.info("girlList()");
? ? ? ?return ?girlRepository.findAll();
? ?}

? ?@PostMapping(value = "/girls")
? ?public Girl add(@Valid Girl girl,
? ? ? ? ? ? ? ? ? ?BindingResult bindingResult){
? ? ? ?if(bindingResult.hasErrors()){
? ? ? ? ? ?//System.out.println(bindingResult.getFieldError().getDefaultMessage());
? ? ? ? ? ?logger.info(bindingResult.getFieldError().getDefaultMessage());
? ? ? ? ? ?return null;
? ? ? ?}
? ? ? ?return girlRepository.save(girl);

? ?}
? /* public Girl add(@RequestParam("cupSize")String cupSize,
? ? ? ? ? ? ? ? ? ? ?@RequestParam("age")Integer age){
? ? ? ?Girl girl = new Girl();
? ? ? ?girl.setAge(age);
? ? ? ?girl.setCupSize(cupSize);

? ? ? ?return girlRepository.save(girl);

? ?}*/

? ?@GetMapping(value = "/girls/{id}")
? ?public Girl get(@PathVariable("id")Integer id){
? ? ? ?return girlRepository.findOne(id);
? ?}

? ?@PutMapping(value = "/girls/{id}")
? ?public Girl update(@PathVariable("id")Integer id,
? ? ? ? ? ? ? ? ? ? ? @RequestParam("cupSize")String cupSize,
? ? ? ? ? ? ? ? ? ? ? @RequestParam("age")Integer age){
? ? ? ?Girl girl = new Girl();
? ? ? ?girl.setId(id);
? ? ? ?girl.setCupSize(cupSize);
? ? ? ?girl.setAge(age);

? ? ? ?return girlRepository.save(girl);

? ?}

? ?@DeleteMapping(value = "/girls/{id}")
? ?public void delete(@PathVariable("id")Integer id){
? ? ? ?girlRepository.delete(id);
? ?}

? ?@GetMapping(value = "girls/age/{age}")
? ?public List<Girl> girlListByAge(@PathVariable("age")Integer age){
? ? ? ?return ?girlRepository.findByAge(age);
? ?}

? ?@PostMapping(value = "/girls/two")
? ?public void girlTwo(){
? ? ? ?girlService.insertTwo();
? ?}

}

0 回復(fù) 有任何疑惑可以回復(fù)我~
#1

未卜先知 提問(wèn)者

解決了,寫(xiě)的時(shí)候按照idea提示加了Spring下的jpa,不是Spring boot下的jpa,所以找不到 import org.springframework.data.jpa.repository.JpaRepository; 這個(gè)導(dǎo)入是一模一樣的
2017-05-30 回復(fù) 有任何疑惑可以回復(fù)我~
#2

為伊塵心 回復(fù) 未卜先知 提問(wèn)者

我也沒(méi)想到這個(gè)
2017-05-30 回復(fù) 有任何疑惑可以回復(fù)我~
#3

我愛(ài)lyf 回復(fù) 未卜先知 提問(wèn)者

我可以問(wèn)一下,這是什么意思嗎?我也出現(xiàn)了同樣的問(wèn)題,百度了一下午,不知道該怎么解決~
2017-10-20 回復(fù) 有任何疑惑可以回復(fù)我~
#4

深藍(lán)d 回復(fù) 未卜先知 提問(wèn)者

所以是怎么改的呢
2019-05-16 回復(fù) 有任何疑惑可以回復(fù)我~
查看1條回復(fù)

@Component
@ConfigurationProperties(prefix = "girl")
public class GirlProperties {


黑體文字加了嗎?

回復(fù)你不能加黑體,你看這個(gè)回復(fù) ?黑體部分


0 回復(fù) 有任何疑惑可以回復(fù)我~
#1

未卜先知 提問(wèn)者

GirlProperties這個(gè)類(lèi)前面肯定是加了@Component的 但是要注入的是GirlRepository,不是GirlProperties,這兩者沒(méi)關(guān)系啊
2017-05-30 回復(fù) 有任何疑惑可以回復(fù)我~

@RestController
public class GirlController {

? ?@Autowired
? ?private ?GirlRepository girlRepository;


注意上面加粗的文字

0 回復(fù) 有任何疑惑可以回復(fù)我~
#1

未卜先知 提問(wèn)者

@RestController public class GirlController { @Autowired private GirlRepository girlRepository; @GetMapping(value = "/girls") public List<Girl> girlList(){ return girlRepository.findAll(); } } 這個(gè) 按道理 我都寫(xiě)了啊
2017-05-30 回復(fù) 有任何疑惑可以回復(fù)我~
#2

為伊塵心 回復(fù) 未卜先知 提問(wèn)者

@Component @ConfigurationProperties(prefix = "girl") public class GirlProperties { 黑體文字加了嗎?
2017-05-30 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消
2小時(shí)學(xué)會(huì)Spring Boot
  • 參與學(xué)習(xí)       151527    人
  • 解答問(wèn)題       1132    個(gè)

Spring Boot入門(mén)視頻教程,你將學(xué)會(huì)使用Spring Boot快速構(gòu)建應(yīng)用程序

進(jìn)入課程

'com.example.demo.GirlRepository' that could not be found.GirlRepository(已解決)

我要回答 關(guān)注問(wèn)題
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢(xún)優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)