Hello! Quick question for Kotlin users with Spring...
# server
g
Hello! Quick question for Kotlin users with Spring.. When you are using constructor injection with spring do you keep the constructor classes as nullable or not nullable? for example;
Copy code
@Service
class FirestoreService(
  private val firestore: Firestore?,
)
vs.
Copy code
@Service
class FirestoreService(
  private val firestore: Firestore,
)
m
Nullable type: If you make an injected bean type nullable, then the injection will be considered as non-required, which is equal to:
Copy code
@Service
class FirestoreService(
  @Autowired(required = false)
  private val firestore: Firestore?,
)
Not nullable type: Injection is required, Spring will throw an error if it cant satisfy a property
g
alright this makes sense!
m
Yeah, also note that Spring checks the property for the
@Nullable
annotation too