Skip to content

Commit

Permalink
fix typos
Browse files Browse the repository at this point in the history
  • Loading branch information
erwan-serandour committed Jan 24, 2025
1 parent 723e32b commit cf3abe4
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions rules/S7178/java/rule.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ This rule raises an issue when a static will is annotated with @Value, @Inject,

Either use an instance field instead of a static field or remove the @Value, @Inject, or @Autowired annotation and initialize the field.


=== Code examples

==== Noncompliant code example
Expand All @@ -23,8 +22,8 @@ Either use an instance field instead of a static field or remove the @Value, @In
@Component
public class MyComponent {
@Autowired
private static SomeDependency dependency; // Noncompliant, @Autowired will be ignored and no value will be injected
@Value("${my.app.prop}")
private static SomeDependency dependency; // Noncompliant, @Value will be ignored and no value will be injected
// ...
}
----
Expand All @@ -36,18 +35,12 @@ public class MyComponent {
@Component
public class MyComponent {
@Value("${my.app.prop}")
private final SomeDependency dependency;
@Autowired
public ExampleClass(SomeDependency dependency) {
this.dependency = dependency;
}
// ...
}
----

== Resources
//=== Documentation
=== Articles & blog posts
* Java Guides - https://www.baeldung.com/spring-inject-static-field

0 comments on commit cf3abe4

Please sign in to comment.