Azure-Samples/azure-spring-boot-samples

[BUG] Appconfig and cosmos give 'sample.convert.UserRepository' that could not be found.

survivant opened this issue · 3 comments

Describe the bug

bug.zip

Unable to start the application when I activate the App configuration.

Exception or Stack Trace

Field repository in sample.convert.ConvertSampleApplication required a bean of type 'sample.convert.UserRepository' that could not be found.

The injection point has the following annotations:
        - @org.springframework.beans.factory.annotation.Autowired(required=true)

To Reproduce
added the environment variables and mvn spring-boot:run

Code Snippet
I apply all the steps that were in the readme.md : https://github.com/Azure-Samples/azure-spring-boot-samples/tree/main/appconfiguration/azure-spring-cloud-appconfiguration-config/azure-spring-cloud-appconfiguration-config-convert-sample/azure-spring-cloud-appconfiguration-config-convert-sample-initial

Expected behavior
the application should works

Setup (please complete the following information):

  • OS: Windows 10
  • IDE: IntelliJ
  • Sample Path:
  • Library/Libraries: com.azure.spring:spring-cloud-azure-starter-data-cosmos:4.5.0, com.azure.spring:azure-spring-cloud-appconfiguration-config:2.11.0
  • Java version: 17
  • Frameworks: Spring Boot 2.7.8

Additional context
I replaced my endpoint by : https://XXX.azconfig.io in those logs

 .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::                (v2.7.8)

2023-01-25 10:57:35.549  INFO 14876 --- [           main] c.azure.identity.EnvironmentCredential   : Azure Identity => EnvironmentCredential invoking ClientSecretCredential
2023-01-25 10:57:35.562  INFO 14876 --- [           main] c.a.c.i.jackson.JacksonVersion           : Package versions: jackson-core=2.13.4, jackson-databind=2.13.4-2, jackson-dataformat-xml=2.13.4, jackson-datatype-jsr310=2.13.4, azure-core=1.34.0, Troubleshooting version conflicts: https://aka.ms/azsdk/java/de
pendency/troubleshoot
2023-01-25 10:57:36.931  INFO 14876 --- [nPool-worker-19] c.azure.identity.ClientSecretCredential  : Azure Identity => getToken() result for scopes [https://XXX.azconfig.io/.default]: SUCCESS
2023-01-25 10:57:36.932  INFO 14876 --- [nPool-worker-19] c.a.c.implementation.AccessTokenCache    : Acquired a new access token.
2023-01-25 10:57:37.062  INFO 14876 --- [           main] c.azure.identity.EnvironmentCredential   : Azure Identity => EnvironmentCredential invoking ClientSecretCredential
2023-01-25 10:57:37.492  INFO 14876 --- [nPool-worker-19] c.azure.identity.ClientSecretCredential  : Azure Identity => getToken() result for scopes [https://vault.azure.net/.default]: SUCCESS
2023-01-25 10:57:37.492  INFO 14876 --- [nPool-worker-19] c.a.c.implementation.AccessTokenCache    : Acquired a new access token.
2023-01-25 10:57:37.545  INFO 14876 --- [           main] b.c.PropertySourceBootstrapConfiguration : Located property source: [BootstrapPropertySource {name='bootstrapProperties-/application/https://XXX.azconfig.io/'}]
2023-01-25 10:57:37.548  INFO 14876 --- [           main] sample.convert.ConvertSampleApplication  : No active profile set, falling back to 1 default profile: "default"
2023-01-25 10:57:37.855  INFO 14876 --- [           main] o.s.cloud.context.scope.GenericScope     : BeanFactory id=15f9cc46-5654-3bd0-8948-a145c05c5920
2023-01-25 10:57:37.893  WARN 14876 --- [           main] s.c.a.AnnotationConfigApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'convertSampleApplication': Unsatisfied dependency expressed through field 'repository'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'sample.convert.UserRepository' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springf
ramework.beans.factory.annotation.Autowired(required=true)}
2023-01-25 10:57:37.900  INFO 14876 --- [           main] ConditionEvaluationReportLoggingListener : 

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2023-01-25 10:57:37.913 ERROR 14876 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   :

***************************
APPLICATION FAILED TO START
***************************

Description:

Field repository in sample.convert.ConvertSampleApplication required a bean of type 'sample.convert.UserRepository' that could not be found.

The injection point has the following annotations:
        - @org.springframework.beans.factory.annotation.Autowired(required=true)


Action:

Consider defining a bean of type 'sample.convert.UserRepository' in your configuration.

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  7.674 s
[INFO] Finished at: 2023-01-25T10:57:38-05:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.7.8:run (default-cli) on project azure-spring-cloud-appconfiguration-config-convert-sample-initial: Application finished with exit code: 1 -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
PS C:\to-delete\azure-spring-boot-samples\appconfiguration\azure-spring-cloud-appconfiguration-config\azure-spring-cloud-appconfiguration-config-convert-sample\azure-spring-cloud-appconfiguration-config-convert-sample-initial> 

Information Checklist

  • [ X] Bug Description Added
  • [ X] Repro Steps Added
  • [ X] Setup information Added

any help would be appreciated to to solve the sample. I tried few different configurations but I'm not able to get it to work.

stliu commented

duplicated by Azure/azure-sdk-for-java#33165, closing this