0

我在 Spring MVC 中很新,我有以下问题。

在我正在处理的应用程序中,我将 2 个控制器类声明到两个不同的包中。

所以我试图在我的 XML 配置中指定必须由组件扫描设置扫描的第二个包。

因此,如果我只有这个设置可以正常工作(但我只扫描一个包):

<context:component-scan base-package="it.mycompmany.myproject.registrazione"></context:component-scan>

但是如果我尝试指定必须扫描两个不同的包,这样:

<!-- Controller -->
<context:component-scan base-package="it.mycompmany.myproject.registrazione">
</context:component-scan>

<context:component-scan base-package="it.mycompmany.myproject.login>
</context:component-scan>

Eclipse 在第二个组件扫描设置标签上给我错误:

The value of attribute "base-package" associated with an element type "context:component-scan" must not contain the '<' character.

问题是什么?如何正确指定我必须扫描两个不同的包?我错过了什么?

4

2 回答 2

1

您可以使用逗号指定多个包

<context:component-scan base-package="it.mycompmany.myproject.registrazione,it.mycompmany.myproject.login">
</context:component-scan>
于 2016-04-12T11:16:38.657 回答
-2

Change from

<!-- Controller -->
<context:component-scan base-package="it.istruzione.iam.ssum.registrazione">
</context:component-scan>

<context:component-scan base-package="it.istruzione.iam.ssum.login>
</context:component-scan>

to

<!-- Controller -->
<context:component-scan base-package="it.istruzione.iam.ssum.registrazione">
</context:component-scan>

<context:component-scan base-package="it.istruzione.iam.ssum.login">
</context:component-scan>
于 2016-04-12T11:10:24.927 回答