Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autowired @Value from Spring Config #193

Closed
kart2018 opened this issue Sep 20, 2018 · 4 comments
Closed

Autowired @Value from Spring Config #193

kart2018 opened this issue Sep 20, 2018 · 4 comments

Comments

@kart2018
Copy link

kart2018 commented Sep 20, 2018

  • Framework version: 2.0.3
  • Implementations: Spring Boot

Scenario
I am looking to get the properties value from Spring Config -> Artifactory, in my DB config i have used the Autowired @value , looks like the properties is not able to find by LambdaHandler.

I am getting the below error,

at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:373)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1350)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:580)

Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.example.util.dbutil' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoMatchingBeanFound(DefaultListableBeanFactory.java:1509)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1104)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1065)

My Lambda Handler is below,

public class TestLambdaHandler implements RequestStreamHandler {

  private SpringBootLambdaContainerHandler<AwsProxyRequest, AwsProxyResponse> handler;
static {
    try {
        handler = SpringBootLambdaContainerHandler.getAwsProxyHandler(Application.class);
    } catch (ContainerInitializationException e) {
        // Re-throw the exception to force another cold start
        e.printStackTrace();
        throw new RuntimeException("Could not initialize Spring Boot application", e);
    }
}

@Override
public void handleRequest(InputStream inputStream, OutputStream outputStream, Context context) throws IOException {
    handler.proxyStream(inputStream, outputStream, context);

    // just in case it wasn't closed by the mapper
    outputStream.close();
}

}

Need your help to fix this code.

@sapessi
Copy link
Collaborator

sapessi commented Sep 21, 2018

Hi @kart2018, we have not tested the framework with SpringBoot 2.x - see issue #181. Can you paste here some more code? Specifically where the @Autowired property is declared and the bean it should get the value from?

@sapessi sapessi added this to the Release 1.3 milestone Oct 22, 2018
@jaympatel1893
Copy link

How can I help?

@sapessi
Copy link
Collaborator

sapessi commented Dec 22, 2018

@kart2018 In the core branch of this repository I have a sample that works with SpringBoot 2.x - could you test with your code against the 1.3-SNAPSHOT in the core branch? Make sure the use the Application config from the springboot2 sample

@sapessi
Copy link
Collaborator

sapessi commented Dec 26, 2018

Resolving in preparation for 1.3 release

@sapessi sapessi closed this as completed Dec 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants