Expand my Community achievements bar.

SOLVED

Maven Install: Errors : @Component : Class must have public default constructor error

Avatar

Level 6

I have created an interface and then its Implementation.

When I run mvn clean install -e -X > installerrors.txt my text file has the following error

[ERROR] C:\Users\clive\git\Shoprite.Holdings.StoreLocator\Shoprite.Holdings.StoreLocator\bundle\src\main\java\shoprite\holdings\impl\StoreLocatorImpl.java [1:1]: @Component : Class must have public default constructor: shoprite.holdings.impl.StoreLocatorImpl

[ERROR] Failed to execute goal org.apache.felix:maven-scr-plugin:1.20.0:scr (generate-scr-descriptor) on project Shoprite.Holdings.StoreLocator-bundle: SCR Descriptor parsing had failures (see log) -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.felix:maven-scr-plugin:1.20.0:scr (generate-scr-descriptor) on project Shoprite.Holdings.StoreLocator-bundle: SCR Descriptor parsing had failures

 

 

public interface IStoreLocator {    
    public ArrayList<Stores> getStores() throws Exception;
    public ArrayList<FacilityTypes> getFacilityTypes() throws Exception;
}

 

@Service

@Component
public class StoreLocatorImpl implements IStoreLocator {

    private ArrayList<Stores> storesArrayList = new ArrayList<Stores>();
    private ArrayList<FacilityTypes> facilityTypesArrayList = new ArrayList<FacilityTypes>();
    private String urlAddress = ""; 

    public StoreLocatorImpl(String s) {
        urlAddress = s;        
    }

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hope you have defined both the method that has been declared in IStoreLocator interface.

Also, try giving service name property for @Service 

View solution in original post

2 Replies

Avatar

Correct answer by
Level 10

Hope you have defined both the method that has been declared in IStoreLocator interface.

Also, try giving service name property for @Service 

Avatar

Level 6

Thank you. I have done as you suggested and it resolved my error.