Für eine mit @SpringbootApplication kommentierte Klasse: < /p>
- Der Name der Klasse sollte mit der Anwendung enden < /li>
Es sollte nur eine Klasse im gesamten Projekt mit @SpringbootApplication < /li>
Die Klasse geben Sollte öffentlich sein - Die Klasse sollte nichts enthalten, kein Feld, keine Konstante, nichts anderes als eine öffentliche statische Leere Hauptmethode.
Code: Select all
@SpringBootApplication
public class MySpringBootApplication {
public static void main(final String[] args) {
SpringApplication.run(MySpringBootApplication.class);
}
}
< /code>
oben wäre ein gültiger Fall. < /p>
Ich versuche die Regel zu schreiben: < /p>
@Test
void springBootApplicationClassShouldOnlyContainOneMethodAndNothingElse() {
classes()
.that()
.areAnnotatedWith(SpringBootApplication.class)
.should()
.haveNameMatching(".*Application")
.check(importedClasses);
}