Git Product home page Git Product logo

ehayik / spring-injected-null-beans-issue Goto Github PK

View Code? Open in Web Editor NEW
0.0 0.0 0.0 14 KB

When I was migrating a maven project implemented with Spring to Spring Boot 1.5.20.RELEASE. I realized of this issue related with a ``final public`` method inside a non ``final`` class annotated with ``@Transactional``, causing injected beans within class became ``null`.

Java 100.00%
spring spring-boot issues

spring-injected-null-beans-issue's Introduction

Spring injected beans are null using Lombok and Constructor Injection

When I was migrating a maven project implemented with Spring to Spring Boot 1.5.20.RELEASE. I realized of this issue related with a final public method inside a non final class annotated with @Transactional, causing injected beans within class became ``null`.

In order to resolve the issue I could reproduce it in this small project. For more information visit stackoverflow

Which technologies are being used

The project uses the following technologies:

  • Spring Boot v1.5.20.RELEASE
  • Spring Data JPA
  • Hibernate
  • H2 embedded database
  • Lombock

Prerequisites and getting started

In order to run the application you must have JDK 8 installed on your local machine. The solution has been tested on JDK 8 update 172.

During the start process the solution will execute two sql scripts to create the database shema (schema.sql) and import test data (data.sql)

When you have JDK 8 installed you need to perform the following steps:

  1. Execute the following command on the command line ./mvnw clean install
  2. The implemented unit test should fail for the update operation because of the bug.
  3. Go to UserServiceImpl.java file and remove de final keyword in line 19.
  4. Save changes and perform step 1, once again. The unit test should not fail during its execution

spring-injected-null-beans-issue's People

Contributors

ehayik avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.