Spring bean not auto-negotiation with @Component annotation

Not sure what I'm doing wrong, but I have a webapp configuration that works in Unit Testing but dies during production for the bean component.

bean extends WebServiceGatewaySupportand extends the interface.

I define it in java as follows:

@Component("myShippingImplementation")
public class MyShippingImplemenation extends WebServiceGatewaySupport implements ShippingImplementation {
    private String addressValidationUri;

    public String getAddressValidationUri() {
        return addressValidationUri;
    }

    public void setAddressValidationUri(String addressValidationUri) {
        this.addressValidationUri = addressValidationUri;
    }   
}

and XML bean configuration:

<bean id="myShippingImplementation" class="com.cerp.service.shipping.MyShippingImplemenation" autowire="byType">
    <property name="addressValidationUri" value="https://www.testurl.com" />
    <property name="defaultUri"           value="https://www.alturl.com" />
    <property name="marshaller" ref="marshaller"/>
    <property name="unmarshaller" ref="marshaller"/>
</bean>

If I connect this to Unit test, it will work:

public class MyServiceClientTest extends BaseWebServiceTest {
    @Autowired MyShippingImplemenation c;

(BaseWebServiceTest uses SpringJUnit4ClassRunner)

but if I connect it to the controller and start it with Tomcat with the following:

@Controller
@RequestMapping(value="/work/settings")
public class SettingsController {
    @Autowired
    SignupServiceI signupService;

    @Autowired
    ShippingImplementation myShipImplementation;

. , , XML, bean, . , setAddressValidationUri, , . bean null .

, SignupServiceI... bean, autowire. , , @Service.

+4
1

@Component.

bean ( bean , - bean name/id). XML. XML - , .

+10

Source: https://habr.com/ru/post/1540322/


All Articles