Skip to content

Instantly share code, notes, and snippets.

@adbourne
Created August 28, 2025 20:15
Show Gist options
  • Select an option

  • Save adbourne/d44c23aa44284c7fbb1f7d6a2af718ff to your computer and use it in GitHub Desktop.

Select an option

Save adbourne/d44c23aa44284c7fbb1f7d6a2af718ff to your computer and use it in GitHub Desktop.
Log out beans
/** Do not use in prod */
package com.devtiro.secureweb;
import jakarta.annotation.PostConstruct;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import java.util.Arrays;
@SpringBootApplication
public class SecurewebApplication {
@Autowired
private ApplicationContext applicationContext;
public static void main(String[] args) {
SpringApplication.run(SecurewebApplication.class, args);
}
@PostConstruct
public void printBeans() {
String[] beanNames = applicationContext.getBeanDefinitionNames();
System.out.println("Loaded beans count: " + beanNames.length);
Arrays.stream(beanNames)
.sorted()
.forEach(System.out::println);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment