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

Unable to Use Azure Data Storage in Springboot #1923

Open
uhexos opened this issue Apr 30, 2024 · 3 comments
Open

Unable to Use Azure Data Storage in Springboot #1923

uhexos opened this issue Apr 30, 2024 · 3 comments

Comments

@uhexos
Copy link

uhexos commented Apr 30, 2024

Describe the bug
Attempting to use the spring-content-azure-storage package results in error below on application start
Parameter 1 of constructor in com.zone.firstaccount.controller.FileContentController required a bean of type 'com.zone.firstaccount.repository.PromoContentStore' that could not be found.

To Reproduce
Steps to reproduce the behavior:

  1. Add fs starter, add spring-content-azure-storage, add needed bom dependency
<dependency>
           <groupId>com.github.paulcwarren</groupId>
           <artifactId>spring-content-fs-boot-starter</artifactId>
           <version>3.0.9</version>
       </dependency>
       <dependency>
           <groupId>com.github.paulcwarren</groupId>
           <artifactId>spring-content-azure-storage</artifactId>
           <version>3.0.9</version>
       </dependency>
       <dependency>
           <groupId>com.github.paulcwarren</groupId>
           <artifactId>spring-content-bom</artifactId>
           <version>3.0.9</version>
       </dependency>
  1. Add config
@Configuration
@EnableAzureStorage
public  class ApplicationConfigAzure {

        @Value("#{environment.AZURE_STORAGE_ENDPOINT}")
        private String endpoint;

        @Value("#{environment.AZURE_STORAGE_CONNECTION_STRING}")
        private String connString;

        @Bean
        public BlobServiceClientBuilder storage() {
                return new BlobServiceClientBuilder()
                .endpoint(endpoint)
                .connectionString(connString);
        }
}
  1. Add Entity
@Entity
@Getter
@Setter
@NoArgsConstructor
public class Promo {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id", nullable = false)
    private Long id;
    private String name;
    private LocalDate dob;
    private Boolean hasbankAccount;
    private Boolean hasPolicy;

    @ContentId
    private String contentId;
    @ContentLength
    private long contentLength;
    private String contentMimeType = "text/plain";
}
  1. Add Store and Entity Repo , app refuses to start without @repository annotation
@Repository
public interface PromoContentStore extends ContentStore<Promo, String> {
}
public interface PromoRepository extends CrudRepository<Promo, Long> {
}

Expected Behavior:
The application should start up without any errors, and the FileContentController should be instantiated correctly with the required PromoContentStore dependency.

Actual Behavior:
The application fails to start due to the error mentioned above, indicating that the PromoContentStore bean cannot be found.
Suffer the error. However fs which is setup in another config not show works just fine

@paulcwarren
Copy link
Owner

paulcwarren commented May 1, 2024

Hi @uhexos , you can take a look at this example to see how it can be set up. Run the test to see the context loads.

HTH

@paulcwarren
Copy link
Owner

Ping. @uhexos did that help?

@uhexos
Copy link
Author

uhexos commented May 21, 2024

@paulcwarren gave it a try but clearly I'm not smart enough to figure it out. In the end I gave up and just stuck with regular file system. When that's insufficient I'll take a look at azure again. Will try to recreate and post the actual error. Thanks for the help either ways @paulcwarren

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants