Java Spring on Windows 10 Part 1: Spring Framework

🌿1. Install Spring Framework

Install Apache Common Logging API

Install Spring Framework

🍳2. Setup Eclipse

Add Spring Libraries

☕️3. Create a Spring Demo

Hello.java: prints a message.

public class Hello {
private String msg;

public void setChicken (String s) {
this.msg = s;
}

public void getChicken() {
System.out.println("Message: "+msg);
}
}

SpringApp.java handles the application context.

public class SpringApp {

public static void main(String[] args) {
ApplicationContext context =
new ClassPathXmlApplicationContext(
"com/homanspring/Beans.xml");
Hello mHello =
(Hello) context.getBean("hello");
mHello.getChicken();
}
}

Bring in the Addon to Ease Your Work.

Create Beans.XML

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans-4.3.xsd">


</beans>
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns=...>

<bean id = "hello" class = "com.homanspring.Hello">
<property name = "chicken" value = "Hello to Spring World!"/>
</bean>

</beans>
Message: Hello to Spring World!

Enjoy!

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store