Web

[Spring]_#1

롶롶예 2021. 7. 12. 16:54

1) 스프링 정의

   - 간단히 스프링이라 지칭하지만 정확하게는 스프링 프레임워크 (Spring Framework) 라고 하는 것이 정확한 표현.'

 

  * 자바(JAVA) 플랫폼을 위한 오픈소스(Open Source) 애플리케이션 프레임워크(Framework)
  * 자바 엔터프라이즈 개발을 편하게 해주는 오픈 소스 경량급 애플리케이션 프레임워크
  * 자바 개발을 위한 프레임워크로 종속 객체를 생성해주고,  조립해주는 도구
  * 자바로 된 프레임워크로 자바SE로 된 자바 객체(POJO)를 자바EE에 의존적이지 않게 연결해주는 역할.


 

Gradle 연결

 

 

buildscript {
ext{
springBootVersion = '2.1.7.RELEASE'
}
repositories {
mavenCentral()
jcenter()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'

group 'com.jojoldu.book'
version '1.0-SNAPSHOT'
sourceCompatibility = 11


repositories {
mavenCentral()
}

dependencies {
compile('org.springframework.boot:spring-boot-starter-web')
testCompile('org.springframework.boot:spring-boot-starter-test')

testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.0'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.7.0'
}

test {
useJUnitPlatform()
}

 

 


Hello 예제

 

다음과 같이 클래스와 패키지, 리소스파일 생성

 

HelloController                                                    Application

 

resource >>application.properties

application.properties에 server.port=7070 를 작성

 

main을 실행시킨 후 크롬 주소창에 localhost:7070(포트번호) 를 작성하면

다음과 같이 hello 출력한다. localhost:7070/hello 를 붙이게 되면 HelloController 클래스 내의 

위 부분의 함수가 실행되어 웹 페이지에 hello Controller 가 나오게 된다.