惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

B
Blog RSS Feed
美团技术团队
Attack and Defense Labs
Attack and Defense Labs
博客园 - 三生石上(FineUI控件)
Y
Y Combinator Blog
IT之家
IT之家
GbyAI
GbyAI
博客园_首页
酷 壳 – CoolShell
酷 壳 – CoolShell
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
博客园 - 聂微东
量子位
阮一峰的网络日志
阮一峰的网络日志
Hugging Face - Blog
Hugging Face - Blog
Recent Announcements
Recent Announcements
月光博客
月光博客
The GitHub Blog
The GitHub Blog
V
Visual Studio Blog
D
DataBreaches.Net
Microsoft Azure Blog
Microsoft Azure Blog
博客园 - 司徒正美
罗磊的独立博客
人人都是产品经理
人人都是产品经理
U
Unit 42
宝玉的分享
宝玉的分享
V
V2EX
雷峰网
雷峰网
C
Cyber Attacks, Cyber Crime and Cyber Security
博客园 - 叶小钗
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
L
LINUX DO - 热门话题
Engineering at Meta
Engineering at Meta
P
Palo Alto Networks Blog
Scott Helme
Scott Helme
Cisco Talos Blog
Cisco Talos Blog
Apple Machine Learning Research
Apple Machine Learning Research
Cyberwarzone
Cyberwarzone
腾讯CDC
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
C
Cybersecurity and Infrastructure Security Agency CISA
爱范儿
爱范儿
V
Vulnerabilities – Threatpost
Martin Fowler
Martin Fowler
P
Privacy & Cybersecurity Law Blog
S
Securelist
Google DeepMind News
Google DeepMind News
小众软件
小众软件
T
Threat Research - Cisco Blogs
D
Darknet – Hacking Tools, Hacker News & Cyber Security
L
LangChain Blog

博客园 - PPBoy

状态机的轮子 oracle生成path的sql语句 oracle表空间异常大 springboot2集成activiti出错 策略模式2 策略模式1 sql从n月到m月数据汇总,没有数据,当月显示0 jsp下拉列表 dao层取值用List<map<String,Object>>接收有序map 在线预览pdf springboot打jar包,调用webservice出错 导出到word ueditor后台配置项返回格式出错,上传功能将不能正常使用 js控制多层单选,多选按钮,做隐藏操作 js控制全屏及退出全屏 第九篇: 高可用的服务注册中心 第八篇: 服务链路追踪(Spring Cloud Sleuth) 第七篇: 消息总线(Spring Cloud Bus) 第六篇: 分布式配置中心(Spring Cloud Config)
springboot2.0jar包启动异常
PPBoy · 2018-10-09 · via 博客园 - PPBoy

今天碰到一个异常:

08:44:07.214 [main] ERROR org.springframework.boot.SpringApplication - Application run failed
org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.s
: Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean.

提示明显,没有servletweb容器。

按说springboot是有内置容器的。后来查找看到帖子:https://blog.csdn.net/riyunzhu/article/details/63259718

但是我的jdk1.8,没有问题,估计版本兼容问题。按照上述的解决方案,在启动类添加代码:

    @Bean
    public EmbeddedServletContainerFactory servletContainer() {
        TomcatEmbeddedServletContainerFactory factory = 
                      new TomcatEmbeddedServletContainerFactory();
        return factory;
     }

提示找不到 EmbeddedServletContainerFactory类。查找后知道:EmbeddedServletContainerFactory找不到,是springboot2.X之后改了写法。

详情参见帖子:https://blog.csdn.net/l4642247/article/details/81631770

后改为:

    @Bean
    public TomcatServletWebServerFactory servletContainer() {
        TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory();
        return factory;
    }

打包成功,可以正常启动项目了。

在这里贴下idea快捷键:https://www.cnblogs.com/zhangpengshou/p/5366413.html

idea打包maven项目:https://www.jb51.net/article/141962.htm

以前都用thymeleaf,记录下spring项目支持jsp

<!-- 使用 jsp 必要依赖 -->
    <dependency>
      <groupId>org.apache.tomcat.embed</groupId>
      <artifactId>tomcat-embed-jasper</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>jstl</artifactId>
    </dependency>

 另外:打包后,启动jar包显示“中没有主清单属性” 需要在配置中将

MANIFEST.MF放到main/resources下。

另外需要maven打包jsp需要添加:

<build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
        <resources>
            <resource>
                <!-- 指定resources插件处理哪个目录下的资源文件 -->
                <directory>src/main/webapp</directory>
                <!--注意此次必须要放在此目录下才能被访问到 -->
                <targetPath>META-INF/resources</targetPath>
                <includes>
                    <include>**/**</include>
                </includes>
            </resource>
        </resources>
    </build>