10 Spring and Spring Boot Common Mistakes You Need To STOP

Ғылым және технология

In this video I will discuss 10 Spring Framework and Spring Boot Mistakes you need stop right now. This is crucial to write clean code.
When writing web app with spring framework and spring boot there are best practices to follow in order to build scalable backend applications.
#springframework #springboot #java
00:00 - Intro
00:22 - Leaking Internals
01:54 - Records
03:36 - Dependency Injection
05:28 - Separation Of Concern
07:16 - Error Handling
09:48 - Testing
12:23 - Annotation Validation
14:43 - Logging
15:15 - XML
Number 10 was Immutability which I forgot to talk about.
Don't Forget to
===========================================
💯 Subscribe to Amigoscode - bit.ly/2HpF5V8
💯 Courses Available for free here - amigoscode.com/courses
💯 Join Private Facebook Group and Discord - amigoscode.com/p/join-community
⭐ Table Of Contents ⭐
===========================================
🙊 Here are the goods for all my videos video 🙊
► Recommended Books
===========================================
- Clean Code - amzn.to/2UGDPlX
- HTTP: The Definitive Guide - amzn.to/2JDVi8s
- Clean Architecture - amzn.to/2xOBNXW
► Computer and Monitor
===========================================
- New Apple MacBook Pro - amzn.to/3464Mmn
- Dell 27 INCH Ultrasharp U2719D Monitor - amzn.to/2xM3nW1
- Double Arm Stand Desk Mount - amzn.to/3aYKKfs
- USB C Hub Multiport Adapter - amzn.to/2Jz7NlL
► Camera Gear
=============================================
- Sony ILCE7M3B Full Frame Mirrorless Camera - amzn.to/346QIJn
- Sigma 16 mm F1.4 DC DN - amzn.to/2wbic3Q
- Sigma 33B965 30 mm F1.4 DC DC - amzn.to/39G37Fd
► IDE & Tools I use for coding 💻 🎒
===========================================
- ITerm
- VsCode
- GoLand
- IntelliJ Ultimate
- Sublime
P.S
===========================================
💯 Don't forget to subscribe | bit.ly/2HpF5V8
💯 Join Private Facebook Group and Discord - amigoscode.com/p/join-community
💯 Follow me on Instagram | bit.ly/2TSkA9w
❤️ Thanks for watching

Пікірлер: 201

  • @zsombortoreky7678
    @zsombortoreky7678 Жыл бұрын

    You've mentioned at the testing part, that we should not use a different database from the production one (eg.: postgres / h2), I would really be interested in seeing a video about these types of best practices, thanks😁

  • @mikeoxlongdnb

    @mikeoxlongdnb

    Жыл бұрын

    kzread.infov3eQCIWLYOw

  • @rhumedisi2783
    @rhumedisi2783 Жыл бұрын

    Thank you very much for this detailed Spring/Spring Boot, "How Not Tos". It's great to see a teacher who consistently and effectively communicate best practices.

  • @marcoreinaldi4193

    @marcoreinaldi4193

    Жыл бұрын

    I agree. I think this video is great and give me insight how to avoid mistake on Springboot. But I hope, he will publish another video with the solution on how to do it right. Not the whole thing, but maybe just an Idea how to do it right.

  • @codingsavid6509
    @codingsavid6509 Жыл бұрын

    Can you make a video on propertly error handling?

  • @V4dk4n

    @V4dk4n

    Жыл бұрын

    Read about @ControllerAdvice annotation.

  • @andreinovosiolov
    @andreinovosiolov Жыл бұрын

    Thank you for this video. I'm a trainee and you videos are very helpful. Waiting for lesson about proper testing of a Spring Boot application.

  • @majesty8309
    @majesty83092 ай бұрын

    I have learnt something new. Thank you very much Nelson

  • @geni4551
    @geni4551 Жыл бұрын

    Thank you very much for the explanation. Would love to see why we should not use H2 for testing video! :)

  • @khaganimammadli6846
    @khaganimammadli6846Күн бұрын

    Hi, you are my fav youtuber, you explain clearly and i understand almost everything. I wait from you the best tutorial about functional programming, lamda, streams and etc from zero to hero with simple explanation

  • @MrTutiplengo
    @MrTutiplengo Жыл бұрын

    Awesome content. I'm new to Spring Boot and this was very informative. I didn't know about Java records at all.

  • @narek-tm
    @narek-tm Жыл бұрын

    Thanks for your content. Please, make video tutorials on testing in Spring Boot, especially integration testing, test containers.

  • @heduardos26
    @heduardos26 Жыл бұрын

    Great video, thanks a lot! We'll love to see a video where you explain how to test with the same DB and not use H2.

  • @feloniousmonkey
    @feloniousmonkey Жыл бұрын

    Great content...your points are ones that I do see fairly often. Keep the vids coming 😀

  • @just_O
    @just_O Жыл бұрын

    A small glance of how beautiful code can be, thanks for sharing

  • @tedac091
    @tedac09110 ай бұрын

    I've been looking up on how to make the switch from H2 database to tests containers. I would really appreciated a video on it, thank you!

  • @aminesafi7261
    @aminesafi7261 Жыл бұрын

    For the @Autowired annotation, you should use it if you have more than one constructor otherwise Spring will fail to inject the dependencies, it is a kind of a hint to tell spring which constructor to use. Nice video and very good explanation, keep going 💪🏻

  • @igle85

    @igle85

    Жыл бұрын

    You shouldn't have 2 constructor for services, it's not a good practice.

  • @aminesafi7261

    @aminesafi7261

    Жыл бұрын

    @@igle85 I agree, I’m just explaining that we can find ourselves in this situation.

  • @Denys.Stoianov

    @Denys.Stoianov

    Жыл бұрын

    @@aminesafi7261 it is possible to pass multiple services to the constructor and it will works even without @Autowired annotation,

  • @aminesafi7261

    @aminesafi7261

    Жыл бұрын

    @@Denys.Stoianov You didn't get it, read my comment again :)

  • @aminesafi7261

    @aminesafi7261

    Жыл бұрын

    @@sweets7092 Your comment is off topic, thanks anyway 🙂

  • @carlosrenesoto9650
    @carlosrenesoto96509 ай бұрын

    Great video @amigoscode Thanks a lot for sharing your knowledge!

  • @niaboktruk
    @niaboktrukАй бұрын

    Amazing content man, I'll watch every video you have. Amazing, simply amazing!!! 🤩

  • @kirasign4605
    @kirasign4605 Жыл бұрын

    Please make other testing video like what you said in this video. Very grateful for this Thanks in advance! Lovely videos like always

  • @user-fy8vj7el5q
    @user-fy8vj7el5q2 ай бұрын

    wow it's 2024 and you're still the best spring youtuber in the whole world

  • @bashirzamani5144
    @bashirzamani5144 Жыл бұрын

    Thank you nelson, please continue this form of videos

  • @marcelohmg
    @marcelohmg Жыл бұрын

    I would really like a video about testing the databese and querys!

  • @bladerunner20446
    @bladerunner20446 Жыл бұрын

    Great content as always. Could you please make more in-depth testing videos

  • @egamberdijabborov6586
    @egamberdijabborov6586 Жыл бұрын

    👍👍👍👍Thanks for the video tutorial

  • @eduardo-1822
    @eduardo-1822 Жыл бұрын

    So cool, very nice tips, thank you buddy

  • @ms-pf9ow
    @ms-pf9ow Жыл бұрын

    I learned a lot. Thank you

  • @Maicrash104
    @Maicrash104 Жыл бұрын

    To Error handling, since Spring 6 you can use "Problem Details" like standard and not have your own ErrorDto

  • @rockdarko440
    @rockdarko440 Жыл бұрын

    Thanks for this! I would really indeed like a video for the case against using H2 for testing. We use Oracle in production (migrating to postgres enterprise in a year or so) and would like to hear what you would suggest here. Thanks again!! :)

  • @MarcoS-mx1vj

    @MarcoS-mx1vj

    Жыл бұрын

    The problem with using In-Memory databases for testing is, that it doesn't make your tests reliable. Its a completeley different database with a different feature set. A green h2-based test doesn't mean that your code will work in production as well. One solution for this would be using a dockerized version of your production database (e.g. by using TestContainers).

  • @rockdarko440

    @rockdarko440

    Жыл бұрын

    @@MarcoS-mx1vj Yes, you are ultimately right and Oracle supplies such containers. But the reality often is that developers don't always have the resources on their laptops to run something as hungry as oracle (even containerized that is a beast) and most of all often lack the knowledge/will to set it up. As an ops I would need to create a deployment for them I guess. It's a real shame to be honest, but that is the reality I deal with personally. The model we use for the time being is devs use H2 locally on their laptop, then deploy in a DEV environment where a full blown Oracle server is and although I wish it weren't that way, it does the job. Thanks for replying!

  • @GFunkEra1992
    @GFunkEra1992 Жыл бұрын

    Thank you brother, very usefull info

  • @nospamallowed4890
    @nospamallowed4890 Жыл бұрын

    Thank you, I did not know about records. Seems like a pretty essential, powerful, and very simple to use feature. If I might suggest a topic for a future tutorial that has NOT been covered properly by anybody: Spring Boot 3 + Spring Security 6 + Tomcat 10 (deploy webapp as WAR) + Azure AD authentication & authorization using Microsoft's spring-cloud-azure-starter-active-directory Maven dependency. For extra points or as part of another tutorial... how to handle libraries (like the microsoft dependency above) that use logback when you are deploying to a Tomcat 10 that is configured for log4j2 logging (throws a logback exception when it tries to cast LogbackServletContainerInitializer to jakarta ServletContainerInitializer). Both of the tutorial topics I mention are fairly common configurations that nobody seems to be covering.

  • @robertwhite3503

    @robertwhite3503

    Жыл бұрын

    I often use the actual entities rather than DTO's. These may work with persistence, but I cannot see a sensible way to use records with annotation-based data validation.

  • @darpanshirsat1712
    @darpanshirsat17123 ай бұрын

    Thanks you Buddy!

  • @zafarboymurotov764
    @zafarboymurotov764 Жыл бұрын

    Thank you very much good luck

  • @sakthisomaskandan6438
    @sakthisomaskandan643811 ай бұрын

    Great video as always! Can you please make a video on why not to use h2 for testing? Thanks 🙏

  • @diniomar3965
    @diniomar396511 ай бұрын

    Your video is very clear. Whats your setup?

  • @dshakya29
    @dshakya29 Жыл бұрын

    Hi Nelson, please make a series on testing Spring Boot applications.

  • @pguti778
    @pguti778 Жыл бұрын

    Very good video! Yes please go ahead and do a video on testing!! Another mistake: not using lombok!!!

  • @matthewsuprunov4497
    @matthewsuprunov4497 Жыл бұрын

    great video! well explained, thanks can you please show how to manage authentication with jwt, redirecting after success login and managing roles?

  • @limobei5042
    @limobei5042 Жыл бұрын

    Thanks a lot. I learned a lot. Please let me know, how i can learn better testing within spring boot, e.g. use right and necessary parts of apllication context

  • @gabrielalvesgoncalves9959
    @gabrielalvesgoncalves9959 Жыл бұрын

    One of the best videos on the channel! Congratulations again, you are an inspiration!

  • @danielbaptista4925
    @danielbaptista4925 Жыл бұрын

    Hi Nelson! :) Great video, I would love to see a video about database testing with an practical example

  • @482ksd

    @482ksd

    Жыл бұрын

    Second this. Would love to see how you spin up a container with a real DB in it for testing.

  • @Jumataev

    @Jumataev

    Жыл бұрын

    Me also

  • @khalilbouali3480
    @khalilbouali34807 ай бұрын

    thanks a lot !

  • @Denys.Stoianov
    @Denys.Stoianov Жыл бұрын

    I see that you have here at 12:00 FakeS3 class, so it means you modify your production code to be able to test it. Why you do not use in this case localstack, it is also a standard defacto like testcontainers for testing. Correct me if I am wrong and this is just for Demo purpose

  • @jochanoss
    @jochanoss Жыл бұрын

    Essalamu Aleytkum Nelson, I love the way that your IDE looks. Would you make a video of what plugins do you use?

  • @taners
    @taners Жыл бұрын

    hi Nelson, good tricks thank you. which plugins do you use on IntelliJ ?

  • @nayeemrafsan356
    @nayeemrafsan356 Жыл бұрын

    this is goldmine!

  • @mark6662
    @mark6662 Жыл бұрын

    I understand for most instances constructor injection is better than setter injection but what do you mean by you can't mock the dependencies with setter injection. Surely you can just Create the object and then create a mock of the dependency and pass that dependency in through the setter.

  • @TheSpiderWalk
    @TheSpiderWalk Жыл бұрын

    It would be nice to record one video only about testing in spring-boot, I am currently struggling with testing in spring-boot.

  • @LearncodewithMuneeb
    @LearncodewithMuneeb8 ай бұрын

    Thanks sir for making useful videos for us. But I request you very respectfully to work in a project in spring boot having at least 6 entities/tables using spring boot in the back end and React/Angular/Next in the front end

  • @zezoms
    @zezoms Жыл бұрын

    Great content. Keep going

  • @henrikkrievs4274
    @henrikkrievs4274 Жыл бұрын

    Love your vids. Are you familar with a tool, which is capable of listening to several ports on localhost, at the same time? Like a sniffer

  • @usamaabubakar3061
    @usamaabubakar30619 ай бұрын

    Can you give more insights about that logger part? What to log, what not to log, best way to use log, and when to use info, debug, warn and error

  • @abdullaermatov1848
    @abdullaermatov1848 Жыл бұрын

    Would you suggest to use Lombok annotations for getter and setters? Or it is better to do it without lombok?

  • @sphesihlemanuel2933
    @sphesihlemanuel2933 Жыл бұрын

    Happy to learn, I thought Field injection was the that makes it hard to unit test, and Setter and Constructor injection were fine 👏🏾

  • @adambickford8720

    @adambickford8720

    Жыл бұрын

    Not setter injection. An object should be in a useable state once its created. Beans are shared by default so you don't want other playing games with it.

  • @robertwhite3503

    @robertwhite3503

    Жыл бұрын

    Constructor injection offers the guarantee that the object has the required dependencies. Setter injection means that anyone using the object has to remember to inject.

  • @jorgensenabrahamson6479
    @jorgensenabrahamson6479 Жыл бұрын

    Hi, If I am using java 1.8 where the records are not present, which would be the best approach? create a mapper also? or should we use JPA Projections always instead? Could you please make a video about it? thanks

  • @aayush481
    @aayush481 Жыл бұрын

    Hi @Amigoscode, your'e an amazing teacher and mentor, we want to buy your full stack course and learn from you, however the price is too high for people in India, as we have to pay in USD...

  • @richaveli
    @richaveli Жыл бұрын

    Can't wait to see what mistakes I'm already making! 😊

  • @lmrl021
    @lmrl021 Жыл бұрын

    Great video. Can I request for another video for possible solution in one of those mistakes? Thank you.

  • @sacmaliyoruz
    @sacmaliyoruz Жыл бұрын

    salam alaikum brother thanks for everything. you are the best. hi from türkiye

  • @jorgetovar621
    @jorgetovar621 Жыл бұрын

    Whats the theme that you are using? it looks nice

  • @LukmanJaji
    @LukmanJaji Жыл бұрын

    Salam alykun Nelson. Please make a video on why we should not use H2 for testing. Thank you.

  • @sz_peter
    @sz_peter Жыл бұрын

    Setter injection is allowed when more then 7 dependencies required in the given class to avoid the "Method should not have more then X parameters" Sonar issue (if you use any static code analysis tools).

  • @hamsandwich123

    @hamsandwich123

    Жыл бұрын

    tbf if you have 7 dependencies for a class you may want to rethink your design. good chance the class is doing too much and can be broken up into smaller classes.

  • @rostomnouisser4023
    @rostomnouisser4023 Жыл бұрын

    please make tutorials about XLD , Jenkins and déploiement of an application , it's important and you can make it simple

  • @ayed-al-nator
    @ayed-al-nator Жыл бұрын

    nice video ❤❤ thanks

  • @larcenmenlahcen5998
    @larcenmenlahcen5998 Жыл бұрын

    Salam alikom akhy(Brother) good job, keep do it. Ramadan moubarak👉

  • @feloniousmonkey
    @feloniousmonkey Жыл бұрын

    @Valid was correct...@Validated is for partial or group based validation...

  • @luca_raveri
    @luca_raveri9 ай бұрын

    what about field injection with the annotation @Autowired? is this a good practice or should be avoided? if yes, why?

  • @seyedaliroshan2386
    @seyedaliroshan2386 Жыл бұрын

    Salam, can make a video of what is the difference between using lombok @Data annotation and the record classes and which is better? I couldn't find a good compression and really carious about it

  • @jasper-3338
    @jasper-3338 Жыл бұрын

    2. Using records, could have some extra explanation as what it does underwater, basically I use a record with the same variabele name and it looks up a record with that variable name? and returns me a single entity with that name? or multiple within that record? 3. Dependancy @Autowired vs constructor injection, the constructor injection is very good for testing the classes as it can be mocked using mockito. @Autowired is deprecated by spring boot. Good that you give one line for testing, as for testing the dependent classes can be mocked. For the testing is there a sample I can look into ? So I can speed up my own code as well? :)

  • @abhipatel439
    @abhipatel439 Жыл бұрын

    Hey, brother! If it's alright with you, could you possibly make a dedicated video that covers the topic of testing in Spring Boot? It has the potential to greatly benefit your audience.

  • @mujaddidsislam1897
    @mujaddidsislam1897 Жыл бұрын

    this video gives me enlightenment, جَزَاكَ ٱللَّٰهُ

  • @monsuruokuniyi1234
    @monsuruokuniyi1234 Жыл бұрын

    Tests, I'm not doing that enough. We write lots of code at work, and I believe we should also be writing tests along side. But our output rate doesn’t allow it. Can we start writing tests now? It looks like a daunting task

  • @rajkhare5949
    @rajkhare5949 Жыл бұрын

    nice video thanks!!!...why your courses are not available at Udemy??...please start your channel there as well!!

  • @DeGoya
    @DeGoya Жыл бұрын

    Salamu alaykum brother, could you do a video on @Async and CompletableFuture?

  • @adarshverma3372
    @adarshverma3372 Жыл бұрын

    Please make a video on testing Spring Boot Application using Data Sources

  • @mriduljayan4466
    @mriduljayan4466 Жыл бұрын

    Though xml is verbose it does separation of concerns better. The framework is less invasive as all you have is pojos.

  • @ClaudesGomes
    @ClaudesGomes Жыл бұрын

    what extensions do you use in the intellij?

  • @shanagondaarun2436
    @shanagondaarun2436 Жыл бұрын

    What's the theme called. How to apply it. Looks dope

  • @lubodimitrov8778
    @lubodimitrov8778 Жыл бұрын

    could you explain why we shoulnt use xml? do u recommend using gradle?

  • @vacheyepremyan4252
    @vacheyepremyan4252 Жыл бұрын

    thanks

  • @AmaanHasanDilawar
    @AmaanHasanDilawar Жыл бұрын

    Awesome

  • @NotNaveedKhan
    @NotNaveedKhan5 ай бұрын

    Spring Boot provides validation dependency which i more better way to do the validation of request object. Also, I would like to know how do you map the data from request to entity and from entity to response?

  • @sphesihlemanuel2933
    @sphesihlemanuel2933 Жыл бұрын

    Please record a video on testing 👏🏾🙏🏾

  • @Michaeljamieson10
    @Michaeljamieson10 Жыл бұрын

    Highly recommend his full stack course

  • @talbiabdelali5914
    @talbiabdelali5914 Жыл бұрын

    Could you release a full course of Spring boot testing please ?

  • @sweetphilly2
    @sweetphilly2 Жыл бұрын

    Yeah i gotta take some time to learn more about Records. They seem simple yet powerful. Anyone seeing the benefits of them, and mind further explaining their uses?

  • @skynight5207
    @skynight5207 Жыл бұрын

    Could you please make video about domain driven design (ddd) design pattern with spring boot?

  • @Asingh42
    @Asingh42 Жыл бұрын

    14:20 what is diffrence between jakarta validation and spring ones?

  • @alvaroandressuarez
    @alvaroandressuarez Жыл бұрын

    what is the particular IDE you are using in this video?

  • @AdnanAmmanUllah
    @AdnanAmmanUllah Жыл бұрын

    could you please create a detailed video on error handling?

  • @Jumataev
    @Jumataev Жыл бұрын

    Hello Nelson! I really would like to see how you test with real database, because recently I saw your video with a h2 in junit testing.

  • @robertwhite3503

    @robertwhite3503

    Жыл бұрын

    It is interesting that so may demos use H2 for testing.

  • @danielthompson3082
    @danielthompson3082 Жыл бұрын

    what's the difference between @SpringBootTest and @DataJPATest and why should I only use the former once?

  • @KamelBerkani08
    @KamelBerkani084 ай бұрын

    How do you run controllers with IntelliJ ?

  • @lone_warrior3672
    @lone_warrior3672 Жыл бұрын

    Can you please make a video series on Java 8 Stream APIs.

  • @g0thqu054
    @g0thqu054 Жыл бұрын

    Assalemu alaykom brother Sorry for disturbing I would just ask if it is possible to record a video regarding writing tests using dockerized db as you mentioned Also was it possible to record a video where we can learn how to add oauth or another login logic to an existing rest crud app. Many thanks in advance

  • @kazbo4431
    @kazbo4431 Жыл бұрын

    Bro! Thanks for your videos!!! That really good, you the best! Can u record video about how we can effective and easy test JPA methods ? (10:56) Idk how i can test that: should i test crud operations from service layer? or i need test that from clean repository...

  • @robertwhite3503

    @robertwhite3503

    Жыл бұрын

    Generally the advice is to never test the methods that are provided by third parties, like basic CRUD, as they should already be tested. To the extent that you have amended the code with JPQL or specific parameters you should test these. Everything you can do in your main java code can be done in the test code. For example seting up a test databases. Once you have tested the database layer you should not be testing it again. Your service layer tests should mock out the database layer using something like Mockito. If you can save a record in the database layer, there is little to be gained from showing you can save a record in the database from the service layer. Just prove that the service layer is trying to call the mocked database layer. That keeps your service layers quick to test.

  • @diabawii
    @diabawii Жыл бұрын

    Is the code you are explaining in the video is public, and where can i find it if it is ?

  • @ollySun
    @ollySun Жыл бұрын

    How is the fasting going? hope its good. Please do a complete tutorial video on testing

  • @alpiirzptr8052
    @alpiirzptr8052 Жыл бұрын

    which you prefer to use for build, maven or gradle?, currently i using gradle cause gradle dependency download faster than maven, sometime maven take a long time to just update dependency even my internet speed is fast enough to download 1 gb for 5 mnt, now i using vs code to write spring and cmd to run spring, does that also affect maven performance compared to using ide?

  • @IvanRandomDude

    @IvanRandomDude

    Жыл бұрын

    gradle in 2023

  • @LOLdjrabaanLOL

    @LOLdjrabaanLOL

    Жыл бұрын

    only maven

  • @robertwhite3503

    @robertwhite3503

    Жыл бұрын

    I prefer Maven rather than install another language (Groovy). In general the download is the same file files for Maven or Groovy. I am not sure if Gradle uses the Maven Repositories anyway. But with either tool, you download once and the data is stored on the PC for future use. Some IDE's use their own build tools. Others use Maven, or at least allow you to run Maven, just like you are doing.

  • @StefanoRiffaldi
    @StefanoRiffaldi Жыл бұрын

    video about exception handler and validation RIGHT NOW

  • @elvisismaelsalvatierraespi8990
    @elvisismaelsalvatierraespi8990 Жыл бұрын

    Que IDE estás utilizando?

  • @TheKanoxa
    @TheKanoxa Жыл бұрын

    Please please please do a video on testing database without H2. I'm struggling in my work with this 😢

  • @nikolayverkhovtsev3886
    @nikolayverkhovtsev3886 Жыл бұрын

    Is this IDEA or what IDE u use in this video?

Келесі