를 주입 : -멀티 모듈 받는다는 스프링 내가 두 받는다는 모듈이 콩
웹 (봄 자연과 angel이라는 프로젝트를) .JAR하기 위해 포장
로직 (콩 등 봄 프로젝트) - 패킷을 .war
웹 .pom에서 나는 논리에 의존하고있다. 자바 코드 autowired 등 괜찮습니다. 웹 프로젝트의 로직에서 빈을 사용하고 싶습니다.
내 web.xml 파일 (웹 프로젝트) : 경로 : ../src/main/webapp/WEB-INF
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:applicationContext.xml
</param-value>
</context-param>
내 응용 프로그램 컨텍스트 : (경로 : ../src/main/webapp/ WEB-INF)
<beans ...
<context:annotation-config />
<import resource="logic.xml"/>
<context:component-scan base-package="b2b"
annotation-config="true" />
logic.xml은 로직 모듈 콩에 대한 구성을 포함한다. 기본 패키지 이름은 b2b입니다. UI 클래스에서
내가 가진 :
@Autowired
private CompanyService companyService;
나는 콩을 얻기 위해 여러 가지 방법으로 노력하지만, 항상 companyService은 시작 웹 후 null입니다.
로직 모듈에서 bean을 웹 모듈에 표시하려면 무엇을 추가해야합니까?
UI 클래스 :
@Theme("mytheme")
@SuppressWarnings("serial")
@Controller
public class MyVaadinUI extends UI
{ }
angel이라는 V7 여기 언급으로 나는 또한합니다 enter link description here
을하지만, 도움이되지.
이 내 UI 클래스입니다 :
enter code here
@Theme("mytheme")
@SuppressWarnings("serial")
@Controller
public class MyVaadinUI extends UI
{
SpringContextHelper helper = new SpringContextHelper(VaadinServlet.getCurrent().getServletContext());
private static Logger LOGGER = Logger.getLogger(MyVaadinUI.class);
@WebServlet(value = "/*", asyncSupported = true)
@VaadinServletConfiguration(productionMode = false, ui = MyVaadinUI.class, widgetset = "b2b.frontend.AppWidgetSet")
public static class Servlet extends VaadinServlet {
}
@Override
protected void init(VaadinRequest request) {
final VerticalLayout layout = new VerticalLayout();
layout.setMargin(true);
setContent(layout);
final CompanyService companyService = (CompanyService) helper.getBean("companyService");
Button button = new Button("Click Me");
button.addClickListener(new Button.ClickListener() {
public void buttonClick(ClickEvent event) {
//layout.addComponent(new Label("Thank you for clicking"));
LOGGER.info("pushed the button");
layout.addComponent(new Label("aa " +companyService +" Thank you for clicking"));
}
});
layout.addComponent(button);
}
} 당신은 당신의 UI 클래스를 발표하지 않았다