Problem with Bean

Hi Guys

I tried connecting the view to the backend. I followed the tutorial https://vaadin.com/docs/latest/tutorial/database-access

And the starter project from the tutorial works fine. But when I try to implement the same logic in my school project I get the error:


APPLICATION FAILED TO START


Description:

Parameter 0 of constructor in com.cryptoportfoliotracker.logic.AssetManager required a bean named ‘entityManagerFactory’ that could not be found.

Action:

Consider defining a bean named ‘entityManagerFactory’ in your configuration.


I researched a lot in the last few days and all the solutions that I read about aren’t working for me.
What am I missing?

I also tried defining the bean ‘entityManagerFactory’ in my main method.

@Bean(name="entityManagerFactory")
public LocalSessionFactoryBean sessionFactory() {
    LocalSessionFactoryBean sessionFactory = new LocalSessionFactoryBean();

    return sessionFactory;
}

after that I get slightly other error also about the bean creation error. https://gist.github.com/noaboa97/f6429e0f4a725185fa90042dead88ebd

My code is here: https://github.com/noaboa97/cryptoportfoliotracker/tree/dev_connect_view_tobackend/src/main/java/com/cryptoportfoliotracker

Any help would be appreciated. Thanks

Why are you excluding DataSourceAutoConfiguration?

And where is your database configuration in your application.properties?

I did this because I had a problem earlier with JPA.
No there is no DB connection in the properties.

If I don’t exclude it I get other errors related to bean.

https://gist.github.com/noaboa97/a0434b570015e5d3b6771c9357f2fb02

this is with bean ‘entityManagerFactory’ in my main method.

https://gist.github.com/noaboa97/3eebee8ebd97602827cfaacea5472bba
without bean ‘entityManagerFactory’ in my main method.

I did this because I had a problem earlier with JPA.

You have to fix those problems instead of ignoring them. You are just postponing them and they gonna bite you later

Yes, that’s what I’m trying to figure out. But I get so much errors since I’ve been trying to implement JpaRepositories and don’t know where to start fixing those issue. One issue goes away and another one shows up.

Okay so I got almost everything working. Now I just have strange error from the binder:
https://gist.github.com/noaboa97/bba07f010775653bd1cc128027894283
Even though I’m not using the entity Asset in the view component. But Asset extends CryptoAsset.

@positive-impala
Regarding this issue https://gist.github.com/noaboa97/3eebee8ebd97602827cfaacea5472bba
Your @Entity classes aren’t mapped correctly (Asset and Transaction classes)
Basic attribute type should not be persistence entity.
2022-08-29_02-15.png

@beautiful-vespa Yes! Thank you. I figured that out.