BAEL-4083 - sample spring boot app with xml config and properties
This commit is contained in:
+17
@@ -0,0 +1,17 @@
|
||||
package com.baeldung.springbootxml;
|
||||
|
||||
public class Pojo {
|
||||
|
||||
private String field;
|
||||
|
||||
public Pojo() {
|
||||
}
|
||||
|
||||
public String getField() {
|
||||
return field;
|
||||
}
|
||||
|
||||
public void setField(String field) {
|
||||
this.field = field;
|
||||
}
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
package com.baeldung.springbootxml;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.ImportResource;
|
||||
|
||||
@Configuration
|
||||
@EnableAutoConfiguration
|
||||
@ImportResource("classpath:beans.xml")
|
||||
public class SpringBootXmlApplication implements CommandLineRunner {
|
||||
|
||||
@Autowired private Pojo pojo;
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(SpringBootXmlApplication.class, args);
|
||||
}
|
||||
|
||||
public void run(String... args) {
|
||||
System.out.println(pojo.getField());
|
||||
}
|
||||
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
package com.baeldung.springbootxml;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.ImportResource;
|
||||
|
||||
@Configuration
|
||||
@ImportResource("classpath:beansconf.xml")
|
||||
public class SpringBootXmlWithConfigApplication implements CommandLineRunner {
|
||||
|
||||
@Autowired private Pojo pojo;
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(SpringBootXmlWithConfigApplication.class, args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(String... args) throws Exception {
|
||||
System.out.println(pojo.getField());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user