how2j.cn


增值内容,请先登录
完整的 Springboot 模仿天猫项目,使用 Springboot 、Vue.js、shiro、redis、elasticsearch 等一整套技术栈, 从无到有涵盖全部129个知识点,565个开发步骤, 充实 Springboot 项目经验,为简历加上一个有吸引力的砝码.
增值内容,点击购买
使用爬虫已经被系统记录,请勿使用爬虫,增大封号风险。 如果是误封 ,请联系站长,谢谢


HOW2J公众号,关注后实时获知最新的教程和优惠活动,谢谢。


问答区域    
2019-09-26 如果nginx和tomcat不在一台主机上呢
iceSnow

如果,nginx和tomcat不在一台主机上,前端上传的图片要放在nginx上,应该怎么办呀,我想的是在nginx 主机上配置一个ftp服务,在应用上用JAVA的ftp客户端给传过去。。不知道是否可行,站长能说说动静分离的一般实践是怎样的吗




1 个答案

how2j
答案时间:2019-09-27
动静分离一般实践就是n和t在同一个机器上,简单配置一下就ok了。 如果在不同的机器就比较麻烦了,其实不如用 cdn了。 上传的文件,直接发到 cdn就好了, nginx都不用啦。



回答已经提交成功,正在审核。 请于 我的回答 处查看回答记录,谢谢
答案 或者 代码至少填写一项, 如果是自己有问题,请重新提问,否则站长有可能看不到




2019-09-26 打包问题后续
我也不知道什么名




站长大人,确实是环境的问题,我按您的指示下载并打包下面那个小项目后,也出现这样的问题,application都无法正常启动,那这样的环境问题该如何修改呢?
C:\Java\jdk8\bin\java -XX:TieredStopAtLevel=1 -noverify -Dspring.output.ansi.enabled=always -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=51158 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.rmi.server.hostname=localhost -Dspring.liveBeansView.mbeanDomain -Dspring.application.admin.enabled=true -javaagent:C:\jq\IDEA\lib\idea_rt.jar=51159:C:\jq\IDEA\bin -Dfile.encoding=UTF-8 -classpath C:\Java\jdk8\jre\lib\charsets.jar;C:\Java\jdk8\jre\lib\deploy.jar;C:\Java\jdk8\jre\lib\ext\access-bridge-64.jar;C:\Java\jdk8\jre\lib\ext\cldrdata.jar;C:\Java\jdk8\jre\lib\ext\dnsns.jar;C:\Java\jdk8\jre\lib\ext\jaccess.jar;C:\Java\jdk8\jre\lib\ext\jfxrt.jar;C:\Java\jdk8\jre\lib\ext\localedata.jar;C:\Java\jdk8\jre\lib\ext\nashorn.jar;C:\Java\jdk8\jre\lib\ext\sunec.jar;C:\Java\jdk8\jre\lib\ext\sunjce_provider.jar;C:\Java\jdk8\jre\lib\ext\sunmscapi.jar;C:\Java\jdk8\jre\lib\ext\sunpkcs11.jar;C:\Java\jdk8\jre\lib\ext\zipfs.jar;C:\Java\jdk8\jre\lib\javaws.jar;C:\Java\jdk8\jre\lib\jce.jar;C:\Java\jdk8\jre\lib\jfr.jar;C:\Java\jdk8\jre\lib\jfxswt.jar;C:\Java\jdk8\jre\lib\jsse.jar;C:\Java\jdk8\jre\lib\management-agent.jar;C:\Java\jdk8\jre\lib\plugin.jar;C:\Java\jdk8\jre\lib\resources.jar;C:\Java\jdk8\jre\lib\rt.jar;D:\Workspaces\IDEA\IDEA-module-projects\springboot\target\classes;D:\Workspaces\Repository\org\springframework\boot\spring-boot-starter-web\1.5.9.RELEASE\spring-boot-starter-web-1.5.9.RELEASE.jar;D:\Workspaces\Repository\org\springframework\boot\spring-boot-starter\1.5.9.RELEASE\spring-boot-starter-1.5.9.RELEASE.jar;D:\Workspaces\Repository\org\springframework\boot\spring-boot\1.5.9.RELEASE\spring-boot-1.5.9.RELEASE.jar;D:\Workspaces\Repository\org\springframework\boot\spring-boot-autoconfigure\1.5.9.RELEASE\spring-boot-autoconfigure-1.5.9.RELEASE.jar;D:\Workspaces\Repository\org\springframework\boot\spring-boot-starter-logging\1.5.9.RELEASE\spring-boot-starter-logging-1.5.9.RELEASE.jar;D:\Workspaces\Repository\ch\qos\logback\logback-classic\1.1.11\logback-classic-1.1.11.jar;D:\Workspaces\Repository\ch\qos\logback\logback-core\1.1.11\logback-core-1.1.11.jar;D:\Workspaces\Repository\org\slf4j\slf4j-api\1.7.25\slf4j-api-1.7.25.jar;D:\Workspaces\Repository\org\slf4j\jcl-over-slf4j\1.7.25\jcl-over-slf4j-1.7.25.jar;D:\Workspaces\Repository\org\slf4j\jul-to-slf4j\1.7.25\jul-to-slf4j-1.7.25.jar;D:\Workspaces\Repository\org\slf4j\log4j-over-slf4j\1.7.25\log4j-over-slf4j-1.7.25.jar;D:\Workspaces\Repository\org\springframework\spring-core\4.3.13.RELEASE\spring-core-4.3.13.RELEASE.jar;D:\Workspaces\Repository\org\yaml\snakeyaml\1.17\snakeyaml-1.17.jar;D:\Workspaces\Repository\org\hibernate\hibernate-validator\5.3.6.Final\hibernate-validator-5.3.6.Final.jar;D:\Workspaces\Repository\javax\validation\validation-api\1.1.0.Final\validation-api-1.1.0.Final.jar;D:\Workspaces\Repository\org\jboss\logging\jboss-logging\3.3.1.Final\jboss-logging-3.3.1.Final.jar;D:\Workspaces\Repository\com\fasterxml\classmate\1.3.4\classmate-1.3.4.jar;D:\Workspaces\Repository\com\fasterxml\jackson\core\jackson-databind\2.8.10\jackson-databind-2.8.10.jar;D:\Workspaces\Repository\com\fasterxml\jackson\core\jackson-annotations\2.8.0\jackson-annotations-2.8.0.jar;D:\Workspaces\Repository\com\fasterxml\jackson\core\jackson-core\2.8.10\jackson-core-2.8.10.jar;D:\Workspaces\Repository\org\springframework\spring-web\4.3.13.RELEASE\spring-web-4.3.13.RELEASE.jar;D:\Workspaces\Repository\org\springframework\spring-aop\4.3.13.RELEASE\spring-aop-4.3.13.RELEASE.jar;D:\Workspaces\Repository\org\springframework\spring-beans\4.3.13.RELEASE\spring-beans-4.3.13.RELEASE.jar;D:\Workspaces\Repository\org\springframework\spring-context\4.3.13.RELEASE\spring-context-4.3.13.RELEASE.jar;D:\Workspaces\Repository\org\springframework\spring-webmvc\4.3.13.RELEASE\spring-webmvc-4.3.13.RELEASE.jar;D:\Workspaces\Repository\org\springframework\spring-expression\4.3.13.RELEASE\spring-expression-4.3.13.RELEASE.jar com.how2java.springboot.Application

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v1.5.9.RELEASE)

2019-09-26 10:09:20.477  INFO 33780 --- [           main] com.how2java.springboot.Application      : Starting Application on LAPTOP-UIH1EFHN with PID 33780 (D:\Workspaces\IDEA\IDEA-module-projects\springboot\target\classes started by JQ in D:\Workspaces\IDEA\IDEA-module-projects\springboot-war)
2019-09-26 10:09:20.480  INFO 33780 --- [           main] com.how2java.springboot.Application      : No active profile set, falling back to default profiles: default
2019-09-26 10:09:20.509  INFO 33780 --- [           main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@32a068d1: startup date [Thu Sep 26 10:09:20 CST 2019]; root of context hierarchy
2019-09-26 10:09:20.575  WARN 33780 --- [           main] s.c.a.AnnotationConfigApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanDefinitionStoreException: Failed to parse configuration class [com.how2java.springboot.Application]; nested exception is java.lang.IllegalStateException: Failed to introspect annotated methods on class org.springframework.boot.web.support.SpringBootServletInitializer
2019-09-26 10:09:20.584 ERROR 33780 --- [           main] o.s.boot.SpringApplication               : Application startup failed

org.springframework.beans.factory.BeanDefinitionStoreException: Failed to parse configuration class [com.how2java.springboot.Application]; nested exception is java.lang.IllegalStateException: Failed to introspect annotated methods on class org.springframework.boot.web.support.SpringBootServletInitializer
	at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:181) ~[spring-context-4.3.13.RELEASE.jar:4.3.13.RELEASE]
	at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:308) ~[spring-context-4.3.13.RELEASE.jar:4.3.13.RELEASE]
	at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:228) ~[spring-context-4.3.13.RELEASE.jar:4.3.13.RELEASE]
	at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:272) ~[spring-context-4.3.13.RELEASE.jar:4.3.13.RELEASE]
	at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:92) ~[spring-context-4.3.13.RELEASE.jar:4.3.13.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:687) ~[spring-context-4.3.13.RELEASE.jar:4.3.13.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:525) ~[spring-context-4.3.13.RELEASE.jar:4.3.13.RELEASE]
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693) [spring-boot-1.5.9.RELEASE.jar:1.5.9.RELEASE]
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360) [spring-boot-1.5.9.RELEASE.jar:1.5.9.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) [spring-boot-1.5.9.RELEASE.jar:1.5.9.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118) [spring-boot-1.5.9.RELEASE.jar:1.5.9.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107) [spring-boot-1.5.9.RELEASE.jar:1.5.9.RELEASE]
	at com.how2java.springboot.Application.main(Application.java:19) [classes/:na]
Caused by: java.lang.IllegalStateException: Failed to introspect annotated methods on class org.springframework.boot.web.support.SpringBootServletInitializer
	at org.springframework.core.type.StandardAnnotationMetadata.getAnnotatedMethods(StandardAnnotationMetadata.java:163) ~[spring-core-4.3.13.RELEASE.jar:4.3.13.RELEASE]
	at org.springframework.context.annotation.ConfigurationClassParser.retrieveBeanMethodMetadata(ConfigurationClassParser.java:380) ~[spring-context-4.3.13.RELEASE.jar:4.3.13.RELEASE]
	at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:314) ~[spring-context-4.3.13.RELEASE.jar:4.3.13.RELEASE]
	at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:245) ~[spring-context-4.3.13.RELEASE.jar:4.3.13.RELEASE]
	at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:198) ~[spring-context-4.3.13.RELEASE.jar:4.3.13.RELEASE]
	at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:167) ~[spring-context-4.3.13.RELEASE.jar:4.3.13.RELEASE]
	... 12 common frames omitted
Caused by: java.lang.NoClassDefFoundError: javax/servlet/ServletContext
	at java.lang.Class.getDeclaredMethods0(Native Method) ~[na:1.8.0_212]
	at java.lang.Class.privateGetDeclaredMethods(Class.java:2701) ~[na:1.8.0_212]
	at java.lang.Class.getDeclaredMethods(Class.java:1975) ~[na:1.8.0_212]
	at org.springframework.core.type.StandardAnnotationMetadata.getAnnotatedMethods(StandardAnnotationMetadata.java:152) ~[spring-core-4.3.13.RELEASE.jar:4.3.13.RELEASE]
	... 17 common frames omitted
Caused by: java.lang.ClassNotFoundException: javax.servlet.ServletContext
	at java.net.URLClassLoader.findClass(URLClassLoader.java:382) ~[na:1.8.0_212]
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_212]
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349) ~[na:1.8.0_212]
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_212]
	... 21 common frames omitted


Process finished with exit code 1

							


1 个答案

how2j
答案时间:2019-09-27
是不是 maven 版本不一致呢? 和我弄成同一个版本看看能解决吗?



回答已经提交成功,正在审核。 请于 我的回答 处查看回答记录,谢谢
答案 或者 代码至少填写一项, 如果是自己有问题,请重新提问,否则站长有可能看不到





2019-09-25 打包错误
2019-09-24 nginx和tomcat
2019-08-28 项目部署路径
2019-03-25 我觉得楼上说的“打包”是将这个springboot项目打包成war包以便放在linux上,我打包的时候报了这个错
2019-03-08 打包步骤




提问之前请登陆
提问已经提交成功,正在审核。 请于 我的提问 处查看提问记录,谢谢
关于 实践项目-天猫整站Springboot-nginx 的提问

尽量提供截图代码异常信息,有助于分析和解决问题。 也可进本站QQ群交流: 982790551
提问尽量提供完整的代码,环境描述,越是有利于问题的重现,您的问题越能更快得到解答。
对教程中代码有疑问,请提供是哪个步骤,哪一行有疑问,这样便于快速定位问题,提高问题得到解答的速度
在已经存在的几千个提问里,有相当大的比例,是因为使用了和站长不同版本的开发环境导致的,比如 jdk, eclpise, idea, mysql,tomcat 等等软件的版本不一致。
请使用和站长一样的版本,可以节约自己大量的学习时间。 站长把教学中用的软件版本整理了,都统一放在了这里, 方便大家下载: https://how2j.cn/k/helloworld/helloworld-version/1718.html

上传截图