Wpis z mikrobloga

Mam klasę:



public
```**```
 
```**```
class
```**```
 Circle 
```**```
implements
```**```
 Shape

{

``````

    
```**```
private
```**```
 Point center;

``````

    
```**```
public
```**```
 Point getCenter()

    {

        
```**```
return
```**```
 center;

    }

``````

    @Autowired

    @Qualifier(
```_```
"pointA"
```_```
)

    
```**```
public
```**```
 
```**```
void
```**```
 setCenter(Point center)

    {

        
```**```
this
```**```
.center = center;

    }

``````

    @Override

    
```**```
public
```**```
 
```**```
void
```**```
 draw()

    {

        System.out.println(
```_```
"Drawing Circle "
```_```
 + center.getX() + 
```_```
" "
```_```
 + center.getY() );

    }

}

```W swoim pliku xml umieściłem:```
 id=
```_```
"pointA"
```_```
 class=
```_```
"SpringTest.Point"
```_**```
>
```**```

              
``````
 name=
```_```
"x"
```_```
 value=
```_```
"${pointA.pointX}"
```_**```
/>
```**```

              
``````
 name=
```_```
"y"
```_```
 value=
```_```
"${pointA.pointY}"
```_**```
/>
```**```

i dostaje błąd:

Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire method: public void SpringTest.Circle.setCenter(SpringTest.Point); nested exception is org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type [SpringTest.Point] is defined: expected single matching bean but found 2: pointA,pointB

Co może być tego przyczyną? Przecież dodaje @Qualifier więc nie powinno być takiego błędu?

#java #programowanie #spring
  • 13