Skip to content

Commit 6886389

Browse files
committed
refactor: add private constructor to fix PMD UseUtilityClass smell
Signed-off-by: AleGTorres <[email protected]>
1 parent 2da74e9 commit 6886389

File tree

2 files changed

+20
-12
lines changed

2 files changed

+20
-12
lines changed

src/main/java/org/springframework/samples/petclinic/PetClinicApplication.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,12 @@
2929
@ImportRuntimeHints(PetClinicRuntimeHints.class)
3030
public class PetClinicApplication {
3131

32-
public static void main(String[] args) {
33-
SpringApplication.run(PetClinicApplication.class, args);
32+
private PetClinicApplication() {
33+
// prevent instantiation
3434
}
3535

36+
public static void main(String[] args) {
37+
SpringApplication.run(PetClinicApplication.class, args);
38+
}
39+
3640
}

src/test/java/org/springframework/samples/petclinic/MysqlTestApplication.java

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,20 @@
3232
@Configuration
3333
public class MysqlTestApplication {
3434

35-
@ServiceConnection
36-
@Profile("mysql")
37-
@Bean
38-
static MySQLContainer<?> container() {
39-
return new MySQLContainer<>(DockerImageName.parse("mysql:9.2"));
40-
}
35+
private MysqlTestApplication() {
36+
// prevent instantiation
37+
}
4138

42-
public static void main(String[] args) {
43-
SpringApplication.run(PetClinicApplication.class, "--spring.profiles.active=mysql",
44-
"--spring.docker.compose.enabled=false");
45-
}
39+
@ServiceConnection
40+
@Profile("mysql")
41+
@Bean
42+
static MySQLContainer<?> container() {
43+
return new MySQLContainer<>(DockerImageName.parse("mysql:9.2"));
44+
}
45+
46+
public static void main(String[] args) {
47+
SpringApplication.run(PetClinicApplication.class, "--spring.profiles.active=mysql",
48+
"--spring.docker.compose.enabled=false");
49+
}
4650

4751
}

0 commit comments

Comments
 (0)