isFull
354
2019-09-11 21:26:10
4
120

spring 에러


다음처럼 에러가 발생합니다. 도움 부탁드립니다. 인터넷에 같은 에러 찾아보고 했는데 원래 잘 돌아가던 프로젝트였는데 애노테이션도 확인했구요 component scan도 확인 했는데 이렇게 에러가 뜹니다...


org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'cartController': Unsatisfied dependency expressed through field 'prodListDao'; nested exception is org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type 'com.spring.dao.ProdListDAO' available: expected single matching bean but found 2: prodListDAOImpl,prodListDAO
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:596)
	at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:90)
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:374)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1378)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:575)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:498)
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:846)
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:863)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:546)
	at org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:701)
	at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:667)
	at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:715)
	at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:590)
	at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:529)
	at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:169)
	at javax.servlet.GenericServlet.init(GenericServlet.java:158)
	at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1134)
	at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1089)
	at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:761)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:135)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:526)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
	at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:678)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408)
	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:860)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1587)
	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Thread.java:748)
Caused by: org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type 'com.spring.dao.ProdListDAO' available: expected single matching bean but found 2: prodListDAOImpl,prodListDAO
	at org.springframework.beans.factory.config.DependencyDescriptor.resolveNotUnique(DependencyDescriptor.java:221)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1222)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1164)
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:593)
	... 39 common frames omitted
9월 11, 2019 9:03:21 오후 org.apache.catalina.core.ApplicationContext log
심각: 서블릿 [appServlet]을(를) 위한 Servlet.init() 호출이 예외를 발생시켰습니다.
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'cartController': Unsatisfied dependency expressed through field 'prodListDao'; nested exception is org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type 'com.spring.dao.ProdListDAO' available: expected single matching bean but found 2: prodListDAOImpl,prodListDAO
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:596)
	at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:90)
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:374)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1378)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:575)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:498)
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:846)
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:863)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:546)
	at org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:701)
	at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:667)
	at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:715)
	at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:590)
	at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:529)
	at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:169)
	at javax.servlet.GenericServlet.init(GenericServlet.java:158)
	at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1134)
	at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1089)
	at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:761)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:135)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:526)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
	at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:678)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408)
	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:860)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1587)
	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Thread.java:748)
Caused by: org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type 'com.spring.dao.ProdListDAO' available: expected single matching bean but found 2: prodListDAOImpl,prodListDAO
	at org.springframework.beans.factory.config.DependencyDescriptor.resolveNotUnique(DependencyDescriptor.java:221)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1222)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1164)
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:593)
	... 39 more

9월 11, 2019 9:03:21 오후 org.apache.catalina.core.StandardWrapperValve invoke


package com.spring.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.inject.Inject;
import javax.servlet.http.HttpSession;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

import com.spring.dao.ProdListDAO;
import com.spring.dto.BasketDTO;
import com.spring.dto.BasketProduct;
import com.spring.dto.CategoryDTO;
import com.spring.dto.ProductDTO;
import com.spring.service.CartService;
import com.spring.service.CategoryService;


@Controller
@RequestMapping("/cart/*")
public class CartController {

	private static final Logger logger=
			LoggerFactory.getLogger(CartController.class);
	
	@Inject
	CartService cartService;
	
	@Inject
	CategoryService categoryService;
	
	@Inject 
	ProdListDAO prodListDao;
	
	@RequestMapping("cartAdd.do")
	public ModelAndView list(@RequestParam String pspec, @RequestParam String pqty, @RequestParam String pnum,ModelAndView mav) {
		/*System.out.println("#####pspec:"+ pspec);
		System.out.println("#####pqty:"+ pqty);
		System.out.println("#####pnum:"+ pnum);*/
		Map<String, Object> map = new HashMap<>();
		List<CategoryDTO> cListAll = categoryService.categoryAll();
		cartService.addProd(prodListDao, pnum, Integer.parseInt(pqty.trim()), pspec);
		List<ProductDTO> pdtos = cartService.getAllProducts();
		map.put("cListAll", cListAll);
		map.put("pdtos", pdtos);
		mav.setViewName("cart/cartList");
		mav.addObject("map", map);
		return mav;
		
	}
	
	@RequestMapping("orderList.do")
	public ModelAndView orderList(ModelAndView mav, HttpSession session) {
		Map<String, Object> map = new HashMap<>();
		List<CategoryDTO> cListAll = categoryService.categoryAll();
		String memID = (String)session.getAttribute("userid");
		//System.out.println("######memID:"+ memID);
		if(memID==null|| memID=="") {
			mav.setViewName("member/login");
			mav.addObject("message", "logout");
			return mav;
		}else {
		String addr = cartService.getMemAddress(memID);
		List<ProductDTO> pdtos = cartService.getAllProducts();
		map.put("addr", addr);
		map.put("cListAll", cListAll);
		map.put("pdtos", pdtos);
		mav.setViewName("cart/orderList");
		mav.addObject("map", map);
		return mav;
		}
	}
	
	@RequestMapping("finalOrder.do")
	public ModelAndView finalOrder(ModelAndView mav, HttpSession session) {
		Map<String, Object> map = new HashMap<>();
		List<CategoryDTO> cListAll = categoryService.categoryAll();
		String memID = (String)session.getAttribute("userid");	
		String addr = cartService.getMemAddress(memID);
		cartService.insertToBasket(memID);
		
		List<BasketProduct> pdtos = cartService.getProductList(memID);
		System.out.println("#######numbers:"+ pdtos.get(0).getNumbers());
		map.put("pdtos", pdtos);
		map.put("addr", addr);
		map.put("cListAll", cListAll);
		
		mav.setViewName("cart/finalOrder");
		mav.addObject("map", map);
		return mav;
		
	}
	
	@RequestMapping("finalOrderList.do")
	public ModelAndView finalOrderList(ModelAndView mav, HttpSession session) {
		Map<String, Object> map = new HashMap<>();
		List<CategoryDTO> cListAll = categoryService.categoryAll();
		String memID = (String)session.getAttribute("userid");
		if(memID==null|| memID=="") {
			mav.setViewName("member/login");
			mav.addObject("message", "logout");
			return mav;
		}else {
		String addr = cartService.getMemAddress(memID);
		List<BasketProduct> pdtos = cartService.getProductList(memID);
		if(pdtos.size()==0) {
			map.put("message", "empty");
		}else {
		map.put("pdtos", pdtos);
		map.put("addr", addr);
		}
		map.put("cListAll", cListAll);
		
		mav.setViewName("cart/finalOrder");
		mav.addObject("map", map);
		return mav;
		}
	}
	@RequestMapping("modifyPqty.do")
	public ModelAndView modifyPqty(@RequestParam String pnum, @RequestParam String pqty, ModelAndView mav) {
		cartService.setModify(pnum, pqty);
		Map<String, Object> map = new HashMap<>();
		List<CategoryDTO> cListAll = categoryService.categoryAll();
		List<ProductDTO> pdtos = cartService.getAllProducts();
		map.put("cListAll", cListAll);
		map.put("pdtos", pdtos);
		mav.setViewName("cart/cartList");
		mav.addObject("map", map);
		return mav;
	}
	
	@RequestMapping("cartDel.do")
	public ModelAndView cartDel(@RequestParam String pnum, ModelAndView mav) {
		Map<String, Object> map = new HashMap<>();
		List<CategoryDTO> cListAll = categoryService.categoryAll();
		cartService.delProd(pnum);
		List<ProductDTO> pdtos = cartService.getAllProducts();
		map.put("cListAll", cListAll);
		map.put("pdtos", pdtos);
		mav.setViewName("cart/cartList");
		mav.addObject("map", map);
		return mav;
	}
}





0
0
  • 답변 4

  • Autowired
    551
    2019-09-11 21:39:21

    prodListDao 인터페이스를 구현한 클래스가 2개이상인가봅니다.

    0
  • isFull
    354
    2019-09-11 21:55:32

    <mybatis-spring:scan base-package="com.spring.dao"/> 이걸 빼니까 정상적으로 돌아가는데 이것이 무슨기능을 하는지요?

    0
  • 0
  • isFull
    354
    2019-09-12 12:45:53

    네 감사합니다!

    0
  • 로그인을 하시면 답변을 등록할 수 있습니다.