java - Autowiring standalone application with NoSuchBeanDefinitionException -


i have application, can't run in eclipse or elsewhere.

here class :

package fr.aaa;  import org.springframework.context.applicationcontext; import org.springframework.context.support.classpathxmlapplicationcontext; import org.springframework.stereotype.component;  @component public class computation {      public computation() {     }      public static void main(string[] args) {         applicationcontext context = new classpathxmlapplicationcontext("classpath*:applicationcontext.xml");         computation computer = context.getbean(computation.class);     } } 

and applicationcontext.xml file :

<?xml version="1.0" encoding="utf-8"?>  <beans xmlns="http://www.springframework.org/schema/beans" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:util="http://www.springframework.org/schema/util" xmlns:security="http://www.springframework.org/schema/security" xmlns:context="http://www.springframework.org/schema/context" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"  xsi:schemalocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd     http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd           http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd     http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.1.xsd     http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd     http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.0.3.xsd">    <import resource="classpath:spring/persistence.xml"/>  <context:annotation-config /> <context:component-scan base-package="fr.aaa.*, com.bbb.*"/>   <util:properties id="jdbcprops" location="jdbc.properties" />     <bean id="propertyconfigurer"     class="org.springframework.beans.factory.config.propertyplaceholderconfigurer">     <property name="locations">         <list>          <value>classpath:configuration.properties</value>          <value>classpath:jdbc.properties</value>         </list>     </property> </bean> 

i exception :

exception in thread "main" org.springframework.beans.factory.nosuchbeandefinitionexception: no unique bean of type [fr.aaa.computation] defined: expected single bean found 0: 

am missing here ?

change

fr.aaa.* 

to

fr.aaa 

do same thing packages.

the base-package attribute is

the comma-separated list of packages scan annotated components. 

there no wildcards involved. have use specific name of package. spring take care of scanning sub packages.


Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -