아주 간단한 예제 소스를 CLI를 이용해서 실행한다.



파일 다운로드 해서 압축을 푼다.

http://repo.spring.io/release/org/springframework/boot/spring-boot-cli/1.3.6.RELEASE/spring-boot-cli-1.3.6.RELEASE-bin.zip


임의의 경로에 풀면 됨 - "C:\Users\사용자\DEV\"


압축 풀면 spring.bat과 spring 파일이 있는 bin 폴더가 있을꺼야


C:\Users\heeyoung\사용자\spring-boot-cli-1.3.6.RELEASE-bin\spring-1.3.6.RELEASE\bin


이 경로 기억해두고..


예제 소스를 실행해보면되. (책에 나온 예제 소스야...ㅎ 나도 groovy는 잘 몰라..)


예제 소스 (HelloController.groovy)


@RestController

class HelloController {

    @RequestMapping("/")

    def hello(){

        return "Hello World"

    }

}     



CLI를 이용해서 소스 실행

C:\Users\사용자\Desktop>C:\Users\heeyoung\DEV\spring-boot-cli-1.3.6.RELEASE-bin\spring-1.3.6.RELEASE\bin\spring run HelloController.groovy


요약하면.. 

> spring run HelloController.groovy


가 되는거야


*** spring 경로를 지정하지 않고 실행하고 싶으면 환경변수의 시스템변수로 지정하면되.

처음 실행하면 좀 시간이 걸려

 Resolving dependencies..........................


이렇게 나오면서 꽤 걸리던데 결국엔 자동으로 spring boot가 실행되면서 내장된 톰캣이 기동되 8080 port로.


> 로그는 이렇게 나와


2017-12-15 14:24:46.273  INFO 8708 --- [       runner-0] o.s.boot.SpringApplication               : Starting application on 사용자-PC with PID 8708 (C:\Users\사용자\.m2\repository\org\springframework\boot\spring-boot\1.3.6.RELEASE\spring-boot-1.3.6.RELEASE.jar started by 사용자 in C:\Users\사용자\Desktop)

2017-12-15 14:24:46.293  INFO 8708 --- [       runner-0] o.s.boot.SpringApplication               : No active profile set, falling back to default profiles: default

2017-12-15 14:24:46.849  INFO 8708 --- [       runner-0] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@2314df83: startup date [Fri Dec 15 14:24:46 KST 2017]; root of context hierarchy


-- 8080 포트로 톰캣 초기화

2017-12-15 14:24:48.931  INFO 8708 --- [       runner-0] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)


-- 톰캣 시작

2017-12-15 14:24:48.949  INFO 8708 --- [       runner-0] o.apache.catalina.core.StandardService   : Starting service Tomcat

2017-12-15 14:24:48.954  INFO 8708 --- [       runner-0] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.0.36


2017-12-15 14:24:49.124  INFO 8708 --- [ost-startStop-1] org.apache.catalina.loader.WebappLoader  : Unknown loader org.springframework.boot.cli.compiler.ExtendedGroovyClassLoader$DefaultScopeParentClassLoader@61d373ca class org.springframework.boot.cli.compiler.ExtendedGroovyClassLoader$DefaultScopeParentClassLoader

2017-12-15 14:24:49.148  INFO 8708 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext

2017-12-15 14:24:49.148  INFO 8708 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 2299 ms

2017-12-15 14:24:49.588  INFO 8708 --- [ost-startStop-1] o.s.b.c.e.ServletRegistrationBean        : Mapping servlet: 'dispatcherServlet' to [/]

2017-12-15 14:24:49.597  INFO 8708 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean  : Mapping filter: 'characterEncodingFilter' to: [/*]

2017-12-15 14:24:49.598  INFO 8708 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean  : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]

2017-12-15 14:24:49.599  INFO 8708 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean  : Mapping filter: 'httpPutFormContentFilter' to: [/*]

2017-12-15 14:24:49.600  INFO 8708 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean  : Mapping filter: 'requestContextFilter' to: [/*]

2017-12-15 14:24:49.876  INFO 8708 --- [       runner-0] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@2314df83: startup date [Fri Dec 15 14:24:46 KST 2017]; root of context hierarchy

2017-12-15 14:24:49.966  INFO 8708 --- [       runner-0] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/]}" onto public java.lang.Object HelloController.hello()

2017-12-15 14:24:49.969  INFO 8708 --- [       runner-0] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)

2017-12-15 14:24:49.970  INFO 8708 --- [       runner-0] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)

2017-12-15 14:24:50.005  INFO 8708 --- [       runner-0] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]

2017-12-15 14:24:50.006  INFO 8708 --- [       runner-0] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]

2017-12-15 14:24:50.051  INFO 8708 --- [       runner-0] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]

2017-12-15 14:24:50.588  INFO 8708 --- [       runner-0] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup


-- 8080포트로 톰캣이 시작됐다.

2017-12-15 14:24:50.707  INFO 8708 --- [       runner-0] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080 (http)

2017-12-15 14:24:50.719  INFO 8708 --- [       runner-0] o.s.boot.SpringApplication               : Started application in 4.942 seconds (JVM running for 32.577)


>> 브라우저로 실행


예제 소스에 있던 Hello World 텍스트가 찍히는거 확인됐지?ㅎㅎ

'Develope > Java&Spring' 카테고리의 다른 글

암/복호화 이슈 - No such provider  (0) 2019.06.11
gradle 외부 라이브러리 추가  (0) 2019.02.28
Apache tika로 Mime-type 가져오기  (0) 2019.02.28
gradle 버전 변경  (0) 2019.02.28

+ Recent posts