1
1
.
.
9
9
.
.
2
2
A
A
p
p
p
p
l
l
i
i
c
c
a
a
t
t
i
i
o
o
n
n
-
-
D
D
e
e
s
s
t
t
i
i
n
n
a
a
t
t
i
i
o
o
n
n
I
I
n
n
f
f
o
o
[
[
G
G
]
]
This tutorial shows how to create Destination Application which will be used to demonstrate CORS functionality.
Destination Application will run on Port 8085 and it will contain Resource that will be called by Source Application.
Destination Application created in this tutorial will have CORS disabled (since this is default Browser's behavior).
This means that this version of Application will be normal Spring Boot Application without any CORS functionality.
Therefore initially Source Application will not be able to access Resource from Destination Application.
In later tutorials we will show how to enable CORS in this Destination Application in different ways.
Application Schema [Results]
Spring Boot Starters
GROUP
DEPENDENCY
DESCRIPTION
Web
Spring Web
Enables @Controller, @RequestMapping and Tomcat Server.
P
P
r
r
o
o
c
c
e
e
d
d
u
u
r
r
e
e
Create Project: springboot_cors_destination (add Spring Boot Starters from the table)
Create Package: controllers (inside main package)
Create Class: MyController.java (inside package controllers)
MyController.java
package com.ivoronline.springboot_cors_source.controllers;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.stereotype.Controller;
@Controller
public class MyController {
@GetMapping("/Hello")
public String hello() {
return "Test";
}
}
http://localhost:8080/Hello
Tomcat
Browser
hello()
R
R
e
e
s
s
u
u
l
l
t
t
s
s
http://localhost:8085/Hello (just to confirm that Application is properly setup)
Application Structure
pom.xml
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>