【发布时间】:2011-11-21 09:50:33
【问题描述】:
当我在我的应用上下文中定义波纹管控制器时,我在尝试使用它时遇到重复错误。
如何将构造函数参数传递给控制器而不收到重复的错误消息?
我的应用程序上下文:
<context:component-scan base-package="org.brickred.socialauth.spring.controller" />
<bean id="socialAuthWebController" class="org.brickred.socialauth.spring.controller.SocialAuthWebController">
<constructor-arg value="http://www.mysite.com/" />
<constructor-arg value="/authSuccess.html" />
<constructor-arg value="/failed.html" />
</bean>
<tx:annotation-driven transaction-manager="txManager"/>
带注释的控制器:
@Controller
@RequestMapping("/socialauth")
public class SocialAuthWebController {
private String baseCallbackUrl;
private String successPageURL;
private String accessDeniedPageURL;
@Autowired
private SocialAuthTemplate socialAuthTemplate;
@Autowired
private SocialAuthManager socialAuthManager;
private final Log LOG = LogFactory.getLog(getClass());
/**
* Constructs a SocialAuthWebController.
*
* @param applicationUrl
* the base URL for this application (with context e.g
* http://opensource.brickred.com/socialauthdemo, used to
* construct the callback URL passed to the providers
* @param successPageURL
* the URL of success page or controller, where you want to
* access sign in user details like profile, contacts etc.
* @param accessDeniedPageURL
* the URL of page where you want to redirect when user denied
* the permission.
*/
@Inject
public SocialAuthWebController(final String applicationUrl,
final String successPageURL, final String accessDeniedPageURL) {
this.baseCallbackUrl = applicationUrl;
this.successPageURL = successPageURL;
this.accessDeniedPageURL = accessDeniedPageURL;
}
...
我收到以下错误:
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'socialAuthWebController' defined in URL [jar:file://Tomcat%207.0/webapps/ROOT/WEB-INF/lib/socialauth-spring-2.0-beta2.jar!/org/brickred/socialauth/spring/controller/SocialAuthWebController.class]: Unsatisfied dependency expressed through constructor argument with index 0 of type [java.lang.String]: : No matching bean of type [java.lang.String] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [java.lang.String] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}
【问题讨论】:
-
不是和stackoverflow.com/questions/4333390/…一样的问题吗?
标签: java spring constructor controller annotations