linux中tomcat配置好启动好之后却打不开网址:(java环境变量没有配置好)
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)
java: 错误: 不支持发行版本 5:
IDEA 报错,无效的源发行版 无效的目标发行版 解决方法_无效的目标发行版: 20-CSDN博客
Error java 错误 不支持发行版本5 ( 完美解决版)_java: 错误: 不支持发行版本 5-CSDN博客
java: 程序包org.springframework.boot不存在:
报错IDEA Terminated with exit code 1-CSDN博客
无法访问org.SpringApplication:
总结:要注意几个点,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项目在本地运行后,怎么进行测试访问?
-
通过浏览器访问:
在浏览器中输入
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!!!竟然犯这种错误,哎。看了这个文章才发现的。
最终终于在服务器上运行起来了,在客户端浏览器输入服务器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的安装与配置: