# 确定 Java 版本 dawang:~ dawang$ java -version java version "1.8.0_91" Java(TM) SE Runtime Environment (build 1.8.0_91-b14) Java HotSpot(TM) 64-Bit Server VM (build 25.91-b14, mixed mode) # 安装 Spring Boot CLI # 这是第一条语句 dawang:~ dawang$ brew tap pivotal/tap ==> Tapping pivotal/tap Cloning into '/usr/local/Library/Taps/pivotal/homebrew-tap'... remote: Counting objects: 16, done. remote: Compressing objects: 100% (14/14), done. remote: Total 16 (delta 2), reused 5 (delta 0), pack-reused 0 Unpacking objects: 100% (16/16), done. Checking connectivity... done. Tapped 9 formulae (50 files, 46.1K) # 这是第二条语句 dawang:~ dawang$ brew install springboot ==> Installing springboot from pivotal/tap ==> Downloading https://repo.spring.io/release/org/springframework/boot/spring-boot-cli/1.3.6.RELEASE/spring-boot-cli-1.3.6.RELEASE-bin.tar. ######################################################################## 100.0% ==> Caveats Bash completion has been installed to: /usr/local/etc/bash_completion.d zsh completion has been installed to: /usr/local/share/zsh/site-functions ==> Summary :beer: /usr/local/Cellar/springboot/1.3.6.RELEASE: 6 files, 8.9M, built in 4 minutes 39 seconds
@RestController
class ThisWillActuallyRun {
@RequestMapping("/")
String home() {
"Hello World"
}
}
# 查找对应的进程号 ps aux | grep nginx # 发送关闭信号 kill -QUIT [nginx 主进程 pid]
dawang$ springj run app.groovy Resolving dependencies....... . ____ _ __ _ _ /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ \\/ ___)| |_)| | | | | || (_| | ) ) ) ) ' |____| .__|_| |_|_| |_\__, | / / / / =========|_|==============|___/=/_/_/_/ :: Spring Boot :: (v1.3.6.RELEASE)
. ____ _ __ _ _ /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ \\/ ___)| |_)| | | | | || (_| | ) ) ) ) ' |____| .__|_| |_|_| |_\__, | / / / / =========|_|==============|___/=/_/_/_/ :: Spring Boot :: (v1.3.6.RELEASE) 2016-07-19 19:29:41.235 INFO 65812 --- [ main] wdx.helloworld.HellowordApplication : Starting HellowordApplication on dawang.local with PID 65812 (/Users/dawang/Documents/DJI/Code/helloword/build/classes/main started by dawang in /Users/dawang/Documents/DJI/Code/helloword) 2016-07-19 19:29:41.239 INFO 65812 --- [ main] wdx.helloworld.HellowordApplication : No active profile set, falling back to default profiles: default 2016-07-19 19:29:41.320 INFO 65812 --- [ main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@545997b1: startup date [Tue Jul 19 19:29:41 CST 2016]; root of context hierarchy 2016-07-19 19:29:42.336 INFO 65812 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup 2016-07-19 19:29:42.353 INFO 65812 --- [ main] wdx.helloworld.HellowordApplication : Started HellowordApplication in 1.865 seconds (JVM running for 3.141) 2016-07-19 19:29:42.354 INFO 65812 --- [ Thread-1] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@545997b1: startup date [Tue Jul 19 19:29:41 CST 2016]; root of context hierarchy 2016-07-19 19:29:42.356 INFO 65812 --- [ Thread-1] o.s.j.e.a.AnnotationMBeanExporter : Unregistering JMX-exposed beans on shutdown Process finished with exit code 0
dependencies {
compile('org.springframework.boot:spring-boot-starter')
testCompile('org.springframework.boot:spring-boot-starter-test')
}
dependencies {
compile('org.springframework.boot:spring-boot-starter')
compile('org.springframework.boot:spring-boot-starter-web')
testCompile('org.springframework.boot:spring-boot-starter-test')
}
package wdx.helloworld.web;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* Created by dawang on 16/7/20.
*/
@RestController
public class HelloController {
@RequestMapping("/hello")
public String index() {
return "Hello World! This is wdxtub.";
}
}
package wdx.helloworld;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.http.MediaType;
import org.springframework.mock.web.MockServletContext;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import wdx.helloworld.web.HelloController;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
import static org.hamcrest.Matchers.equalTo;
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = MockServletContext.class)
@WebAppConfiguration
public class HellowordApplicationTests {
private MockMvc mvc;
@Before
public void setUp() throws Exception {
mvc = MockMvcBuilders.standaloneSetup(new HelloController()).build();
}
@Test
public void getHello() throws Exception {
mvc.perform(MockMvcRequestBuilders.get("/hello").accept(MediaType.APPLICATION_JSON))
.andExpect(status().isOk())
.andExpect(content().string(equalTo("Hello World! This is wdxtub.")));
}
}
wdx +- helloworld +- HelloworldApplication.java <- main class | +- web | +- HelloController.java | +- service | +- CustomerService.java
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.3.6.RELEASE)
2016-07-20 13:11:01.859 INFO 36943 --- [ main] wdx.helloworld.HellowordApplication : Starting HellowordApplication on dawang.local with PID 36943 (/Users/dawang/Documents/DJI/Code/helloword/build/libs/helloword-0.0.1-SNAPSHOT.jar started by dawang in /Users/dawang/Documents/DJI/Code/helloword)
2016-07-20 13:11:01.864 INFO 36943 --- [ main] wdx.helloworld.HellowordApplication : No active profile set, falling back to default profiles: default
2016-07-20 13:11:01.960 INFO 36943 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@67424e82: startup date [Wed Jul 20 13:11:01 CST 2016]; root of context hierarchy
2016-07-20 13:11:03.727 INFO 36943 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)
2016-07-20 13:11:03.750 INFO 36943 --- [ main] o.apache.catalina.core.StandardService : Starting service Tomcat
2016-07-20 13:11:03.752 INFO 36943 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.0.36
2016-07-20 13:11:03.897 INFO 36943 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2016-07-20 13:11:03.897 INFO 36943 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1943 ms
2016-07-20 13:11:04.275 INFO 36943 --- [ost-startStop-1] o.s.b.c.e.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/]
2016-07-20 13:11:04.282 INFO 36943 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2016-07-20 13:11:04.283 INFO 36943 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2016-07-20 13:11:04.283 INFO 36943 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2016-07-20 13:11:04.284 INFO 36943 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
2016-07-20 13:11:04.658 INFO 36943 --- [ main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@67424e82: startup date [Wed Jul 20 13:11:01 CST 2016]; root of context hierarchy
2016-07-20 13:11:04.751 INFO 36943 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/hello]}" onto public java.lang.String wdx.helloworld.web.HelloController.index()
2016-07-20 13:11:04.755 INFO 36943 --- [ main] 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)
2016-07-20 13:11:04.755 INFO 36943 --- [ main] 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)
2016-07-20 13:11:04.810 INFO 36943 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2016-07-20 13:11:04.810 INFO 36943 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2016-07-20 13:11:04.875 INFO 36943 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2016-07-20 13:11:05.028 INFO 36943 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2016-07-20 13:11:05.145 INFO 36943 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080 (http)
2016-07-20 13:11:05.151 INFO 36943 --- [ main] wdx.helloworld.HellowordApplication : Started HellowordApplication in 4.0 seconds (JVM running for 4.484)
java -Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=8000,suspend=n -jar build/libs/helloword-0.0.1-SNAPSHOT.jar
configurations {
compile.exclude module: "spring-boot-starter-tomcat"
}
dependencies {
compile('org.springframework.boot:spring-boot-starter')
compile('org.springframework.boot:spring-boot-starter-web')
compile('org.springframework.boot:spring-boot-starter-undertow')
testCompile('org.springframework.boot:spring-boot-starter-test')
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有