LENATeam / bom-project

Apache License 2.0
1 stars 0 forks source link

recipe_i_9_ii 에러 #5

Open seosej opened 1 year ago

seosej commented 1 year ago

자바 컨피그 파일에 shoppingCart 빈이 존재하지 않아 에러가 발생합니다. 아래와 같이 shoppingCart 빈을 추가해주어야 에러가 발생하지 않습니다.

ch01\recipe_1_9_ii\src\main\java\com\apress\spring6recipes\shop\config\ShopConfiguration.java

package com.apress.spring6recipes.shop.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.apress.spring6recipes.shop.AuditCheckBeanPostProcessor;
import com.apress.spring6recipes.shop.Battery;
import com.apress.spring6recipes.shop.Cashier;
import com.apress.spring6recipes.shop.Disc;
import com.apress.spring6recipes.shop.Product;
import com.apress.spring6recipes.shop.ShoppingCart;
import com.apress.spring6recipes.shop.ProductCheckBeanPostProcessor;

@Configuration
public class ShopConfiguration {

    @Bean
    public static AuditCheckBeanPostProcessor auditCheckBeanPostProcessor() {
        return new AuditCheckBeanPostProcessor();
    }

    @Bean
    public static ProductCheckBeanPostProcessor productCheckBeanPostProcessor() {
        return new ProductCheckBeanPostProcessor();
    }

    @Bean
    public Product aaa() {
        return new Battery("AAA", 2.5, true);
    }

    @Bean
    public Product cdrw() {
        return new Disc("CD-RW", 1.5, 700);
    }

    @Bean
    public Product dvdrw() {
        return new Disc("DVD-RW", 3.0, 4700);
    }

    @Bean
    public Cashier cashier() {
        var path = System.getProperty("java.io.tmpdir") + "/cashier";
        return new Cashier("checkout", path);
    }

    @Bean
    public ShoppingCart shoppingCart(){
        return new ShoppingCart();
    }

}