Ich hatte ein Projekt, das funktionierte, und dann plötzlich aufgehört. Frühling versagtSpring Facette funktioniert nicht, intellij
@Configuration
@Order(2)
public static class RegularSecurityConfigurerAdapter extends WebSecurityConfigurerAdapter {
@Inject
private Environment env;
@Inject
private AjaxAuthenticationSuccessHandler ajaxAuthenticationSuccessHandler;
//Could not autowire. No bean of name 'ajaxAuth..' type found
...
die AjaxAuthenticationSuccessHandler
Klasse zu injizieren sieht wie folgt aus
@Component
public class AjaxAuthenticationSuccessHandler extends SimpleUrlAuthenticationSuccessHandler {
@Autowired
private UserRepository userRepository;
...
ich, dass die Facette entdeckt wurde konfiguriert, aber die Linie, wo die Datei mit dem main
Verfahren sowie @ComponentScan
war rot.
Ist das zu meinem Problem zu tun? Wie informiert Frühling der ajaxAuth..
Klasse? Auch wenn ich zu einem vorher arbeitenden Zweig wechsele, geschieht dies.
Hier ist Application.java
:
@ComponentScan
@EnableAutoConfiguration(exclude = {MetricFilterAutoConfiguration.class, MetricRepositoryAutoConfiguration.class})
public class Application {
private static final Logger log = LoggerFactory.getLogger(Application.class);
@Inject
private Environment env;
@PostConstruct
public void initApplication() {
if (env.getActiveProfiles().length == 0) {
log.warn("No Spring profile configured, running with default configuration");
} else {
log.info("Running with Spring profile(s) : {}", Arrays.toString(env.getActiveProfiles()));
}
}
/**
* Main method, used to run the application.
*/
public static void main(String[] args) throws UnknownHostException, NoSuchAlgorithmException {
if (Cipher.getMaxAllowedKeyLength("AES") <= 128) {
log.error("You need Java Cryptography Extension (JCE) to run the system");
return;
}
TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
System.setProperty("user.timezone", "UTC");
SpringApplication app = new SpringApplication(Application.class);
app.setShowBanner(false);
SimpleCommandLinePropertySource source = new SimpleCommandLinePropertySource(args);
// Check if the selected profile has been set as argument.
// if not the development profile will be added
addDefaultProfile(app, source);
addLiquibaseScanPackages();
Environment env = app.run(args).getEnvironment();
// System.setProperty("javax.net.ssl.trustStore", env.getProperty("server.ssl.key-store"));
// System.setProperty("javax.net.ssl.trustStorePassword", env.getProperty("server.ssl.key-store-password"));
String httpPort = env.getProperty("httpPort");
String httpsPort = env.getProperty("server.port");
String div = "----------------------------------------------------------";
String local = "\tLocal: \t\thttps://127.0.0.1:" + httpsPort;
String external = "\tExternal: \thttps://" + InetAddress.getLocalHost().getHostAddress() + ":" + httpsPort;
if (httpPort != null) {
div += "-----------------------------";
local += " & http://127.0.0.1:" + httpPort;
external += " & http://" + InetAddress.getLocalHost().getHostAddress() + ":" + httpPort;
}
log.info("Access URLs:\n" + div + "\n" + local + "\n" + external + "\n" + div);
}
/**
* Set a default profile if it has not been set
*/
private static void addDefaultProfile(SpringApplication app, SimpleCommandLinePropertySource source) {
if (!source.containsProperty("spring.profiles.active")) {
app.setAdditionalProfiles(Constants.SPRING_PROFILE_DEVELOPMENT);
}
}
/**
* Set the liquibases.scan.packages to avoid an exception from ServiceLocator.
*/
private static void addLiquibaseScanPackages() {
System.setProperty("liquibase.scan.packages", Joiner.on(",").join(
"liquibase.change", "liquibase.database", "liquibase.parser",
"liquibase.precondition", "liquibase.datatype",
"liquibase.serializer", "liquibase.sqlgenerator", "liquibase.executor",
"liquibase.snapshot", "liquibase.logging", "liquibase.diff",
"liquibase.structure", "liquibase.structurecompare", "liquibase.lockservice",
"liquibase.ext", "liquibase.changelog"));
}
}
Ich habe das versucht. Ich lande am selben Ort, an dem ich vorher war:/ – OrangePot
Ist die Anwendungsklasse öffentlich? Haben Sie ungelöste Klassenpfadeinträge? Hast du versucht über Maven/Gradle wieder zu importieren? Schließlich beschädigte Caches von JARs? –
Ich bin mir nicht sicher, was Sie mit Reimport über Maven meinen. Intellij lässt Sie auf eine "Bean" neben "@ ComponentScan" mit den Zeilennummern klicken, ich nehme an, dass dies alle Beans sind, die es behandelt. Da ist die Klasse 'ajaxAuth..java', also ist sie sich dessen bewusst. Ich bin mir nicht sicher, warum es nicht injiziert wird, wenn es sich dessen bewusst ist. – OrangePot