首页 \ 问答 \ 为什么Spring Boot会生成一个jar?(Why does Spring Boot generates a jar?)

为什么Spring Boot会生成一个jar?(Why does Spring Boot generates a jar?)

为什么Spring Boot会生成jar文件输出,因为jar无法部署到容器或应用程序服务器?

快速设置(使用嵌入式容器)很高兴,但最终您必须构建war文件才能正确部署应用程序。

此外,在项目投入生产时,坚持使用弹簧靴也是一个不错的选择? 从我的观点来看,弹簧启动只是一种快速入门的方式,但我不确定它的可靠性。


Why does Spring Boot generates a jar file output, since a jar could not be deployed to a container or an application server?

It's nice to get it quickly set up (with an embedded container), but eventually you will have to build a war file in order to deploy the application properly.

Furthermore, it is a good choice to stick with spring boot also when the project is in production? From my point of view spring boot is just as a quick way to get started, but I'm not sure about it's reliability.


原文:https://stackoverflow.com/questions/29076199
更新时间:2022-10-05 17:10

最满意答案

当您尝试将其发送到REST API端点时,我假设您正在搜索使用Javascript的方法(因为您没有指定您使用的技术)。

经验法则:除非您的目标是重新构建JSON构建器,否则请使用已存在的构建器。

而且,猜猜看,Javascript实现了它的JSON工具! ( 见文件

正如文档中所示,您可以使用JSON.stringify函数将对象(如字符串)转换为符合json的编码字符串,以后可以在服务器端进行解码。

此示例说明了如何执行此操作:

var arr = {
    text: "This is some text"
};
var json_string = JSON.stringify(arr);
// Result is:
// "{"text":"This is some text"}"
// Now the json_string contains a json-compliant encoded string.

您还可以使用其他JSON.parse()方法使用javascript解码JSON客户端( 请参阅文档 ):

var json_string = '{"text":"This is some text"}';
var arr = JSON.parse(json_string);
// Now the arr contains an array containing the value
// "This is some text" accessible with the key "text"

如果这不能解答您的问题,请对其进行编辑以使其更加精确,尤其是您正在使用的技术。 我会相应地编辑这个答案


As you're trying to send it to a REST API endpoint, I'll assume you're searching for ways to do it using Javascript (since you didn't specify what tech you were using).

Rule of thumb: except if your goal is to re-build a JSON builder, use the ones already existing.

And, guess what, Javascript implements its JSON tools ! (see documentation here)

As it's shown in the documentation, you can use the JSON.stringify function to simply convert an object, like a string to a json-compliant encoded string, that can later be decoded on the server side.

This example illustrates how to do so:

var arr = {
    text: "This is some text"
};
var json_string = JSON.stringify(arr);
// Result is:
// "{"text":"This is some text"}"
// Now the json_string contains a json-compliant encoded string.

You also can decode JSON client-side with javascript using the other JSON.parse() method (see documentation):

var json_string = '{"text":"This is some text"}';
var arr = JSON.parse(json_string);
// Now the arr contains an array containing the value
// "This is some text" accessible with the key "text"

If that doesn't answer your question, please edit it to make it more precise, especially on what tech you're using. I'll edit this answer accordingly

相关问答

更多
  • 如何使用markdown[2022-04-13]

    代码 单个回车 视为空格。 连续回车 才能分段。 行尾加两个空格,这里-> 即可段内换行。 *这些文字显示为斜体* **这些文字显示为粗体** 效果 单个回车 视为空格。 连续回车 才能分段。 行尾加两个空格,这里-> 即可段内换行。 这些文字显示为斜体 这些文字显示为粗体 代码 行的开头空4个空格,表示程序代码,例如: C#: //这里显示一些代码,在正文显示中会自动识别语言,进行代码染色,这是一段C#代码 public class Blog { public int Id { get; set; } p ...
  • 你正在寻找的是一个自定义的Doclet实现,它可以通过-doc-generator命令行选项用于scaladoc 。 我无法回答一个预先存在的Doclet实施是否能够满足您的需求,但是一个有前景的实施方案是Extradoc 。 但是,它在一段时间内还没有更新。 在较低级别,您可以通过HTMLFactory Doclet和关联的API(例如HTMLFactory和Template )来实现您自己的目标。 除了Extradoc 1之外,似乎没有任何/很多的例子。 不幸的是,它看起来像ScalaDoc在这方面没有 ...
  • 你应该使用反斜杠scapes来做到这一点: $parameters['text'] = 'you must see [example](example.com) or contact with @exmaple\\_com'; you should use backslash scapes to do so: $parameters['text'] = 'you must see [example](example.com) or contact with @exmaple\\_com';
  • 这是因为您在新行字符后面放置了字符,因此实际的Markdown代码是这样的: ## Heading 2 ## Heading 2 * List item * List item 如何渲染它取决于你的Markdown实现,但是有可能有一些Markdown实现会在第一行的标题之后添加第二行。 您应该删除这些空格,以确保代码如下所示: ## Heading 2 ## Heading 2 * List item * List item 如果这不起作用,请尝试在这些段之间添加空格: ## Headin ...
  • 您需要做的是对API端点执行POST并将您的员工对象序列化为json对象,如下所示: var gizmo = new Product() { Name = "Gizmo", Price = 100, Category = "Widget" }; response = await client.PostAsJsonAsync("api/products", gizmo); if (response.IsSuccessStatusCode) { // Get the URI of the created ...
  • rCharts有几个实用功能可以轻松完成。 我假设您的Rmd文件保存为test.Rmd 。 您可以在此处查看已发布的要点 require(rCharts) payload = create_gist('test.Rmd', description = 'Testing Md to Gist') post_gist(payload, viewer = 'http://gist.github.com/') 这是你在寻找什么? 更新:如果要更新您创建的要点,可以使用update_gist函数,并将gist id ...
  • 您正在使用Android内部Json API。 你需要使用Gson的类。 Call sendLocation(@Body JsonObject jsonObject); 因此导入声明 import com.google.gson.JsonObject; 另一个错误是将Callback作为参数传递给请求 Call call = apiService.sendLocation(jsonObject); call.enqueue(new Callback
  • 当您尝试将其发送到REST API端点时,我假设您正在搜索使用Javascript的方法(因为您没有指定您使用的技术)。 经验法则:除非您的目标是重新构建JSON构建器,否则请使用已存在的构建器。 而且,猜猜看,Javascript实现了它的JSON工具! ( 见文件 ) 正如文档中所示,您可以使用JSON.stringify函数将对象(如字符串)转换为符合json的编码字符串,以后可以在服务器端进行解码。 此示例说明了如何执行此操作: var arr = { text: "This is some ...
  • 如果蓝图仅为v1 ,那么它本身就是它所在位置的一部分,因此它应该包含在HOST : HOST: http://api.clementlevallois.net/apitest/v1/ If the blueprint is about v1 only, it's inherently part of where it's location, therefore it should be included in HOST: HOST: http://api.clementlevallois.net/apite ...
  • 解: