Avatar of chalie001
chalie001

asked on 

Consider defining a bean named in your configuration.

hi am having error in my spring boot
log4j:WARN No appenders could be found for logger (org.jboss.logging).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
663 [main] INFO ncs.app.co.za.NcsApp - Starting NcsApp on Desmand-PC with PID 17780 (C:\projects\NcsApp\bin started by user in C:\projects\NcsApp)
663 [main] INFO ncs.app.co.za.NcsApp - No active profile set, falling back to default profiles: default
2072 [main] INFO ncs.app.co.za.NcsApp - Started NcsApp in 1.948 seconds (JVM running for 2.427)
2074 [main] INFO org.springframework.boot.autoconfigure.logging.ConditionEvaluationReportLoggingListener -

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2182 [main] ERROR org.springframework.boot.diagnostics.LoggingFailureAnalysisReporter -

***************************
APPLICATION FAILED TO START
***************************

Description:

A component required a bean named 'NocIigJDBCTemplate' that could not be found.


Action:

Consider defining a bean named 'NocIigJDBCTemplate' in your configuration.

package ncs.app.co.za;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ImportResource;

@SpringBootApplication
public class NcsApp {
	
	@Autowired
	NocIigJDBCTemplate iigJDBCTempalate;
	

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		SpringApplication.run(NcsApp.class, args);

	}
	
	@Bean
	public CommandLineRunner commandLineRunner(ApplicationContext ctx) {
		return args -> {
			final NocIigJDBCTemplate iigJDBCTempalate = (NocIigJDBCTemplate) ctx.getBean("NocIigJDBCTemplate");
			System.out.println("Listing iig records : ");
			iigJDBCTempalate.displayEmpList();
		};
	}

}

Open in new window

* Eclipse* JDBCJavaJava EE* Spring Framework

Avatar of undefined
Last Comment
Sathish David Kumar N
Avatar of Sathish David  Kumar N
Sathish David Kumar N
Flag of India image

NocIigJDBCTemplate  is that your own bean ? or ?
if your own bean then you need to use annotation for that class @component like that

if its your existing then import that
Avatar of chalie001
chalie001

ASKER

i did this
package com.app.co.za;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ImportResource;
//@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class}, scanBasePackages = {
	//	"ncs.app.co.za"
//})
//@ImportResource({ "classpath*:AppConfig.xml" })
@SpringBootApplication
public class NcsApp {
	
	@Autowired
	NocIigJDBCTemplate iigJDBCTempalate;
	

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		SpringApplication.run(NcsApp.class, args);

	}
	
	@Bean
	public CommandLineRunner commandLineRunner(ApplicationContext ctx) {
		return args -> {
			final NocIigJDBCTemplate iigJDBCTempalate = (NocIigJDBCTemplate) ctx.getBean("NocIigJDBCTemplate");
			System.out.println("Listing iig records : ");
			iigJDBCTempalate.displayEmpList();
		};
	}

}

Open in new window

log4j:WARN No appenders could be found for logger (org.jboss.logging).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
3444 [main] INFO com.co.za.app - Starting app on Desmand-PC with PID 5800 (C:\projects\app\bin started by user in C:\projects\app)
3445 [main] INFO com.co.za.app - No active profile set, falling back to default profiles: default
7789 [main] INFO com.co.za.app - Started app in 7.41 seconds (JVM running for 9.383)
7793 [main] INFO org.springframework.boot.autoconfigure.logging.ConditionEvaluationReportLoggingListener -

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
7933 [main] ERROR org.springframework.boot.diagnostics.LoggingFailureAnalysisReporter -

***************************
APPLICATION FAILED TO START
***************************

Description:

A component required a bean named 'NocIigJDBCTemplate' that could not be found.


Action:

Consider defining a bean named 'NocIigJDBCTemplate' in your configuration.
ASKER CERTIFIED SOLUTION
Avatar of Sathish David  Kumar N
Sathish David Kumar N
Flag of India image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Java
Java

Java is a platform-independent, object-oriented programming language and run-time environment, designed to have as few implementation dependencies as possible such that developers can write one set of code across all platforms using libraries. Most devices will not run Java natively, and require a run-time component to be installed in order to execute a Java program.

102K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo