Java Spring on Windows 10 Part 1: Spring Framework

🌿1. Install Spring Framework

Install Apache Common Logging API

Download the latest version:

Install Spring Framework

Download the latest version: https://repo.spring.io/release/org/springframework/spring/

🍳2. Setup Eclipse

Let’s open a new Java project.

Add Spring Libraries

☕️3. Create a Spring Demo

Let’s add two classes.

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.

Let’s add an addon, Spring Tools, to help us to create the Beans.xml.

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
Homan Huang

Homan Huang

100 Followers

Computer Science BS from SFSU. I studied and worked on Android system since 2017. If you are interesting in my past works, please go to my LinkedIn.