0

I have made a simple spring application followin a tutorial. Running the application gives me no errors in the console.

Problem: But unfortunately I do not get any prints by the program in the console. I am also not able to debug because Eclipse does not stop at the break point.

Note: I have also found a post about the eclipse console but the solutions do not really seem to work for me. I think it is a problem in my project.

Question: Do I have to open a special perspective to see the prinln output in the console?

Main Class:

public class SpringDataDemo {
    public static void main(String[] args) {
        try {
            ApplicationContext context = new ClassPathXmlApplicationContext("resources\\spring-configuration.xml");

            // Fetch the DAO from Spring Bean Factory
            EmployeeDao employeeDao = (EmployeeDao) context.getBean("EmployeeDaoImpl");
            Employee employee = new Employee("Employee123");
            // employee.setEmployeeId("1");

            // Save an employee Object using the configured Data source
            employeeDao.save(employee);
            System.out.println("Employee Saved with EmployeeId " + employee.getEmployeeId());

            // find an object using Primary Key
            Employee emp = employeeDao.findByPrimaryKey(employee.getEmployeeId());
            System.out.println(emp);

            // Close the ApplicationContext
            ((ConfigurableApplicationContext) context).close();
        } catch (BeansException | SQLException e) {
            e.printStackTrace();
        }
    }
}
Community
  • 1
  • 1
jublikon
  • 3,427
  • 10
  • 44
  • 82

1 Answers1

0

I got the Eclipse console broken once in a while too. You might have multiple threads running the same instance, just looking at the wrong console tab. Anyway easiest fix would be to completely restart your system.

KYL3R
  • 3,877
  • 1
  • 12
  • 26
  • I did a restart as you recommende. Unfortunately it did not help. – jublikon Jun 24 '16 at 11:56
  • which version of java/eclipse do you use? try to update eclipse. i have just run successfully example from site with jdk jdk1.7.0_79 and eclipse version Luna Service Release 2 (4.4.2) on Windows 7, Console in eclipse(menu in eclipse: Windows-> Show View->Console) contains: log4j:WARN No appenders could be found for logger (org.springframework.core.env.StandardEnvironment). log4j:WARN Please initialize the log4j system properly. Employee Saved with EmployeeId 2 Employee [employeeId=2, employeeName=Employee123] – user3136131 Jun 24 '16 at 12:16
  • if you have issue with console window please go to http://stackoverflow.com/questions/11112670/how-to-open-console-window-in-eclipse – user3136131 Jun 24 '16 at 12:28