当涉及到 Restful URI 上的尾部斜杠时,我可以引用权威立场吗?罗伊菲尔丁的一个会很棒。网络有两种方式的权威意见。这两个位置是: 尾部斜杠表示资源,而没有则没有。另一个论点是尾部斜杠没有语义价值。是哪个?例子:
@GetMapping(path = "/users/")
public List<User> getUsers() {
....
}
@GetMapping(path = "/users/{id}")
public User getUser(@PathVariable String type) {
.....
}
@PutMapping(path = "/users/")
public User updateUser(@RequestBody User user) {
....
}
@PostMapping(path = "/users/")
public User createUser(@RequestBody User user) {
....
}
@DeleteMapping(path = "/users/{id}")
public void deleteUser(@PathVariable Long id) {
....
}
Run Code Online (Sandbox Code Playgroud)
应该删除尾部斜杠吗?
我正在维护gradle代码,有时在定义任务时使用leftshift运算符<<.它工作正常,但从任务中省略<<运算符也是如此.
我理解左移位运算符的用途如何解释 什么是gradle中的运算符<<(双倍小于)?
所以......我得到了leftshift operator <<的目的.它是为任务添加一组操作,当任务运行时,它将按照输入任务的相同顺序执行操作.我得到它,我可以看到它正常工作.但是,省略<<将导致相同的行为.我可以看到在Gradle中使用<<有意义的地方,但在任务的情况下它似乎是多余的,应该省略.这是正确的还是lefthift操作员有用的目的.
例:
task Foo
task Bar
Foo << {
println "foo action 1"
}
Foo << {
println "foo action 2"
}
Bar {
println "bar action 1"
}
Bar {
println "bar action 2"
}
Run Code Online (Sandbox Code Playgroud)
Foo和Bar表现完全一样.
Nutshell解释:
构建一个非常基本的Eureka Discovery服务器spring boot 2.0.4.还创建了一个使用Eureka发现的基本Eureka服务.启动发现服务器,然后启动该服务.该服务向发现服务器注册,但随后立即取消注册并停止.
详细信息Discovery Server代码:
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
@SpringBootApplication
@EnableEurekaServer
public class DiscoveryServerApplication {
public static void main(String[] args) {
SpringApplication.run(DiscoveryServerApplication.class, args);
}
}
Run Code Online (Sandbox Code Playgroud)
服务:请注意,本例中我将Controller放在主启动应用程序中.
@EnableDiscoveryClient //Want it to registger with the discovery
@SpringBootApplication
@RestController //Obviously not a best practice just an example
public class ServiceApplication {
public static void main(String[] args) {
SpringApplication.run(ServiceApplication.class, args);
}
@Value("${spring.application.name")
private String instance;
@RequestMapping("/")
public String message() {
return "hello from " + instance;
}
}
Run Code Online (Sandbox Code Playgroud)
服务pom.xml:
<?xml …Run Code Online (Sandbox Code Playgroud)