#springboot项目创建与部署

linux中tomcat配置好启动好之后却打不开网址:(java环境变量没有配置好)

linux 配置Java环境变量-CSDN博客

Linux 配置Java环境(图文详细)_⑤ 配置java运行环境linux-CSDN博客

如何创建一个SpringBoot项目?(详细的图文教程)_创建springboot项目-CSDN博客

2023最新版IDEA创建一个SpringBoot项目 (详细教程)_idea2023创建springboot项目-CSDN博客

IDEA 配置本地maven仓库并快速创建Springboot项目!_创建boot项目怎么选择指定maven本地仓库-CSDN博客

idea新建Springboot项目时,maven地址变更为默认地址的一个解决方案_idea创建springboot项目固定maven地址-CSDN博客

maven的配置:

IDEA 这么设置 Maven,再也不用担心依赖下载失败了 - 知乎 (zhihu.com)

解决构建maven工程时,配置了阿里云的前提下,依旧使用中央仓库下载依赖导致失败的问题!!!_the maven wrapper was disabled. the maven bundled -CSDN博客

java: 错误: 不支持发行版本 5

IDEA 报错,无效的源发行版 无效的目标发行版 解决方法_无效的目标发行版: 20-CSDN博客

Error java 错误 不支持发行版本5 ( 完美解决版)_java: 错误: 不支持发行版本 5-CSDN博客

java: 程序包org.springframework.boot不存在:

启动springboot报错:程序包org.springframework.boot不存在--详解_web application could not be started as there was -CSDN博客

报错IDEA Terminated with exit code 1-CSDN博客

无法访问org.SpringApplication:

spring boot 启动报错---java: 无法访问org.springframework.boot.SpringApplication 错误的类文件:_java: 无法访问org.springframework.boot.test.context.sp-CSDN博客

总结:要注意几个点,springboot版本,maven版本,jdk版本,依赖版本。

最好是用jdk8吧 ,要不然服务器运行时也会出问题:

Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/springframework/boot/loader/launch/JarLauncher has been compiled by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 52.0
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(Unknown Source)
        at java.security.SecureClassLoader.defineClass(Unknown Source)

springboot项目创建好之后需要修改的几个点:其余的都可以不修改。

1.pom文件

2.application.properties

打包的话直接package!!!!打包如果出错那就按下列代码进行修改:

<!--
    在工作中,很多情况下我们打包是不想执行测试用例的
    可能是测试用例不完事,或是测试用例会影响数据库数据
    跳过测试用例执
-->
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <configuration>
        <!--跳过项目运行测试用例-->
        <skipTests>true</skipTests>
    </configuration>
</plugin>

史上最全的教程!!!!!!!!!,一步到位!!!

保姆级教程——将springboot项目部署到阿里云服务器(小白包会)_怎么把框架项目放到阿里云公网上-CSDN博客


springboot项目在本地运行后,怎么进行测试访问?

  1. 通过浏览器访问

    在浏览器中输入 http://localhost:8080(假设你的 Spring Boot 项目默认端口是8080),然后按下回车键。如果一切正常,你应该能够看到你的应用程序的欢迎页面或者其他页面内容。

打包部署

运行jar包提示 “XXX中没有主清单属性” “找不到主类”两种解决办法 - 知乎 (zhihu.com)

一直显示

Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.web.servlet.HandlerMapping]: Factory method 'resourceHandlerMapping' threw exception; nested exception is java.lang.IllegalStateException: No ServletContext set

原来是自己打包错误,打包用的plugin中的jar,应该用lifecycle中的package!!!竟然犯这种错误,哎。看了这个文章才发现的。

记录一下使用maven踩坑 :The packaging for this project did not assign a file to the build artifact_mac idea the packaging for this project did not as-CSDN博客

最终终于在服务器上运行起来了,在客户端浏览器输入服务器ip:8080/方法名,可以了,不容易啊,如下图。


   at org.springframework.util.Assert.notEmpty(Assert.java:464)
        at org.springframework.boot.autoconfigure.AutoConfigurationImportSelector.getCandidateConfigurations(AutoConfigurationImportSelector.java:173)
        at org.springframework.boot.autoconfigure.AutoConfigurationImportSelector.getAutoConfigurationEntry(AutoConfigurationImportSelector.java:116)
        at org.springframework.boot.autoconfigure.AutoConfigurationImportSelector$AutoConfigurationGroup.process(AutoConfigurationImportSelector.java:396)
        at org.springframework.context.annotation.ConfigurationClassParser$DeferredImportSelectorGrouping.getImports(ConfigurationClassParser.java:875)
        at org.springframework.context.annotation.ConfigurationClassParser$DeferredImportSelectorGroupingHandler.processGroupImports(ConfigurationClassParser.java:801)
        at org.springframework.context.annotation.ConfigurationClassParser$DeferredImportSelectorHandler.process(ConfigurationClassParser.java:771)
        at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:185)
        at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:315)
        at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:232)
        at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:275)
        at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:95)
        at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:705)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:531)
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141)
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:743)
        at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:390)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:312)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1214)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1203)
        at com.example.demo.DemoApplication.main(DemoApplication.java:11)
21:13:55.017 [main] DEBUG org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext - Closing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@10bbd20a, started on
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.web.servlet.HandlerMapping]: Factory method 'resourceHandlerMapping' threw exception; nested exception is java.lang.IllegalStateException: No ServletContext set

在使用idea进行打包,不用maven进行打包时,遇到上述错误。

idea打包可执行的jar与Error: Invalid or corrupt jarfile问题-CSDN博客

暂未解决。


maven的安装与配置:

maven的下载与安装教程(超详细)_maven安装-CSDN博客

  • 80
    点赞
  • 39
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值