Open xgqfrms opened 5 years ago
https://stackoverflow.com/questions/394616/running-jar-file-on-windows
$ java -jar app.jar
ε₯½ζ ’ε
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
package com.xgqfrms.sb.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class SbController {
@RequestMapping("/hello")
public String index() {
// String jsonString = {"name": "xgqfrms", "role": "admin", "id": 1234567890};
// return "Hello World";
return "{\"name\": \"xgqfrms\", \"role\": \"admin\", \"id\": \"1234567890\"}";
}
}
solution
https://blog.csdn.net/u012898245/article/details/79210635
pom.xml
dependencehttps://mvnrepository.com/search?q=json
org.json/json
Jackson
package com.xgqfrms.sb.controller;
// import org.apache.catalina.User;
import org.json.JSONObject;
// import com.fasterxml.jackson.databind.util.JSONWrappedObject;
// import com.xgqfrms.sb.model.User;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class SbController {
// @RequestMapping("/hello")
@RequestMapping(value = "/hello", method = RequestMethod.GET, produces = "application/json")
public String index() {
// String jsonString = {"name": "xgqfrms", "role": "admin", "id": 1234567890};
// return "Hello World";
// return "{\"name\": \"xgqfrms\", \"role\": \"admin\", \"id\":
// \"1234567890\"}";
// return "{\"name\": \"xgqfrms\", \"role\": \"admin\", \"id\": \"1234567890\"}";
return JSONObject.quote("Hello World");
}
// public User getUser() {
// User user = new User();
// user.setUserName("xgqfrms");
// user.setPassWord("123456789");
// return user;
// }
}
// @RestController
// public class SbController {
// @RequestMapping("/hello")
// public String index() {
// private String response;
// public StringResponse(String s) {
// this.response = s;
// }
// }
// }
Spring Boot ζη¨
https://gitee.com/didispace/SpringBoot-Learning
https://github.com/dyc87112/SpringBoot-Learning
http://blog.didispace.com/Spring-Boot%E5%9F%BA%E7%A1%80%E6%95%99%E7%A8%8B/
https://www.zhihu.com/question/53729800