add slfj logger
This commit is contained in:
parent
3cb402ced7
commit
eaf5935589
|
@ -1,15 +1,21 @@
|
|||
package com.baeldung.springbootxml;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
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.EnableAutoConfiguration;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.ImportResource;
|
||||
|
||||
@SpringBootApplication
|
||||
@Configuration
|
||||
@EnableAutoConfiguration
|
||||
@ImportResource("classpath:beans.xml")
|
||||
public class SpringBootXmlApplication implements CommandLineRunner {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(SpringBootXmlApplication.class);
|
||||
|
||||
@Autowired private Pojo pojo;
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
@ -17,7 +23,7 @@ public class SpringBootXmlApplication implements CommandLineRunner {
|
|||
}
|
||||
|
||||
public void run(String... args) {
|
||||
System.out.println(pojo.getField());
|
||||
logger.info(pojo.getField());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans
|
||||
xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xmlns:p="http://www.springframework.org/schema/p"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd">
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
|
||||
|
||||
<bean class="com.baeldung.springbootxml.Pojo">
|
||||
<property name="field" value="${sample}"></property>
|
||||
|
|
Loading…
Reference in New Issue