知识点
相关文章
更多最近更新
更多spring boot入口类Application—基于springmvc+tomcat切到springboot实战二
2019-03-23 23:43|来源: 网路
spring boot入口类Application
package h.y.n.app; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.context.event.ApplicationEnvironmentPreparedEvent; import org.springframework.boot.web.support.SpringBootServletInitializer; import org.springframework.context.ApplicationListener; import org.springframework.context.annotation.ComponentScan; import org.springframework.core.env.ConfigurableEnvironment; import org.springframework.web.WebApplicationInitializer; @SpringBootApplication @ComponentScan(value = {"h.y.n.config","h.y.n.**.service","h.y.n.support","h.y.n.web"}) public class Application{ public static void main(String[] args) { SpringApplication.run(Application.class, args); } }
直接运行main方法即可启动。具体每个注解是啥意思,咋后面再说
pom文件主要配置:
<parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.5.4.RELEASE</version> </parent> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-freemarker</artifactId> </dependency> </dependencies>
相关问答
更多-
一个最简单的 spring boot restful 例子。[2023-08-01]
建议你这样试试看: 1. 在 Eclipse 中新一个 maven 工程。 2. 修改 pom.xml 文件添加如下内容: 3. org.springframework.boot spring-boot-starter-parent 1.5.9.RELEASE org.springframework.boot spring-boot-starter-web org.springframework.boot spring-boot-starter-actuator org.springframework.bo ... -
现在springboot的框架跟spring不同之处[2022-12-21]
区别如下: Spring 是一个“引擎” Spring MVC 是基于 Spring 的一个 MVC 框架 Spring Boot 是基于 Spring4 的条件注册的一套快速开发整合包 Spring 最初利用“工厂模式”( DI )和“代理模式”( AOP )解耦应用组件。大家觉得挺好用,于是按照这种模式搞了一个 MVC 框架(一些用 Spring 解耦的组件),用开发 web 应用( SpringMVC )。然后有发现每次开发都要搞很多依赖,写很多样板代码很麻烦,于是搞了一些懒人整合包( starter ... -
是不是有一款什么手机软件,可以很自然的拉长腿部?不是美图秀秀,有知道的不?[2022-10-20]
spring -
spring boot 和spring framework到底学哪个啊?[2023-06-13]
先学spring framework吧,把spring 的原理,配置那些东西学会了,理解了再去用spring boot 很容易上手,其实spring boot 就是把很多spring 的配置都简化了,很多东西在properties配置文件里写了之后,spring boot 就会自动帮你把相关的bean配置上,例如你在配置文件里把数据库连接的相关地址,用户,密码配好后,spring boot就会自动帮你把数据库连接池配置好,当然你也可以不用他提供的自动配置功能,完全可以按照你的需求去集成其他的例如dbcp,c ... -
spring与springMVC的问题[2022-11-11]
spring mvc类似于struts的一个MVC开框架,其实都是属于spring,spring mvc需要有spring的架包作为支撑才能跑起来spring mvc类似于struts的一个MVC开框架,其实都是属于spring,spring mvc需要有spring的架包作为支撑才能跑起来。 -
春天的英语怎么读?[2022-05-21]
spring -
如何在没有嵌入式tomcat的情况下启动Spring Boot应用程序?(How do I launch a Spring Boot application without the embedded tomcat?)[2022-03-16]
SpringApplication有一个属性webEnvironment 。 如果Tomcat位于类路径中,但是可以将其设置为false(以编程方式或使用spring.main.webEnvironment ),则默认为true。 SpringApplication has a property webEnvironment. It defaults to true if Tomcat is on the classpath but you can set it to false (programmatic ... -
我个人的建议是肯定使用Spring Boot的原因很多。 首先是Boot是“Spring的未来”。 有了这个话,我想说的是,通过Boot,您可以受益于Spring社区的许多承诺,今天的大多数Spring项目都与Boot完全集成,即使是社区也开始开发基于Boot的许多应用程序。 例如对于管理和监视我可以建议看到Spring Boot Admin 使用弹簧启动,您可以受益于非常好的和有用的功能,如执行器和远程管理和监控,可以改善您的应用程序与生产就绪功能非常有用。 非常好的和强大的属性和配置控件,您可以使用ap ...
-
我遇到了同样的问题,因此我必须查看此页面上的所有解决方案以及相关的解决方案。 没有人对我有好处。 这就是我进行小规模研究的原因,看起来捕获的TCP端口出现问题只是因为Gradle和mvn都不了解TCP端口的子操作。 所以不要杀死进程只需使用命令: $ gradlew –stop (我希望mvn同样存在) 此命令正常关闭由Gradle启动的守护程序并释放由Tomcat端口捕获的守护程序。 I have met the same issue and as result I had to review all ...
-
meskobalazs在构建战争部署时回答了有关资源的问题(但注意src/main/webapp不是作为jar部署中的资源文件夹读取的,您必须在此情况下将其添加为资源)。 当你想要将Spring-Boot应用程序更改为Web部署时,你基本上必须做两件事: 将项目的包装从jar转换为war 将嵌入式tomcat的依赖性改为提供 更多详细信息可以在Spring-Boot文档站点上找到 meskobalazs answered your question about the resources when buil ...