我在 docker 容器中运行一个简单的 spring-boot 应用程序。在启动时,无论是从 java -jar MY_JAR.jar 还是 mvn spring-boot:run 开始,应用程序都会在以下点挂起:
2014-12-22 23:26:58.957 INFO 1 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
这是关键,我只能在 DigitalOcean(1CPU,1GB MEM)的 Ubuntu 14.04 机器上重现它,即使它在容器内运行。在我的本地机器 (mac) 上一切正常。
Dockerfile:
FROM java:8
ADD target/MY_SERVICE-1.0-SNAPSHOT.jar /data/svc.jar
EXPOSE 8080
CMD ["java", "-jar", "/data/svc.jar"]
我尝试过的事情
haveged 库here 有什么建议吗?
感谢您的帮助。
整个日志(以--debug开头):
[Text Art Omitted]
:: Spring Boot :: (v1.1.10.RELEASE)
2014-12-22 19:22:58.375 INFO 20816 --- [ main] com.spectrom.uploadService.Main : Starting Main on spectrom-services with PID 20816 (/root/spectrom-upload-service/target/upload-service-1.0-SNAPSHOT.jar started by root in /root/spectrom-upload-service)
2014-12-22 19:22:58.392 DEBUG 20816 --- [ main] o.s.boot.SpringApplication : Loading source class com.spectrom.uploadService.Main
2014-12-22 19:22:58.671 DEBUG 20816 --- [ main] o.s.b.c.c.ConfigFileApplicationListener : Skipped config file 'file:./config/application.yaml' resource not found
2014-12-22 19:22:58.673 DEBUG 20816 --- [ main] o.s.b.c.c.ConfigFileApplicationListener : Skipped config file 'file:./config/application.properties' resource not found
2014-12-22 19:22:58.674 DEBUG 20816 --- [ main] o.s.b.c.c.ConfigFileApplicationListener : Skipped config file 'file:./config/application.yml' resource not found
2014-12-22 19:22:58.675 DEBUG 20816 --- [ main] o.s.b.c.c.ConfigFileApplicationListener : Skipped config file 'file:./application.yaml' resource not found
2014-12-22 19:22:58.675 DEBUG 20816 --- [ main] o.s.b.c.c.ConfigFileApplicationListener : Skipped config file 'file:./application.properties' resource not found
2014-12-22 19:22:58.676 DEBUG 20816 --- [ main] o.s.b.c.c.ConfigFileApplicationListener : Skipped config file 'file:./application.yml' resource not found
2014-12-22 19:22:58.677 DEBUG 20816 --- [ main] o.s.b.c.c.ConfigFileApplicationListener : Skipped config file 'classpath:/config/application.yaml' resource not found
2014-12-22 19:22:58.678 DEBUG 20816 --- [ main] o.s.b.c.c.ConfigFileApplicationListener : Skipped config file 'classpath:/config/application.properties' resource not found
2014-12-22 19:22:58.679 DEBUG 20816 --- [ main] o.s.b.c.c.ConfigFileApplicationListener : Skipped config file 'classpath:/config/application.yml' resource not found
2014-12-22 19:22:58.679 DEBUG 20816 --- [ main] o.s.b.c.c.ConfigFileApplicationListener : Skipped config file 'classpath:/application.yaml' resource not found
2014-12-22 19:22:58.680 DEBUG 20816 --- [ main] o.s.b.c.c.ConfigFileApplicationListener : Loaded config file 'classpath:/application.properties'
2014-12-22 19:22:58.681 DEBUG 20816 --- [ main] o.s.b.c.c.ConfigFileApplicationListener : Skipped config file 'classpath:/application.yml' resource not found
2014-12-22 19:22:58.693 INFO 20816 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@ddd51a7: startup date [Mon Dec 22 19:22:58 EST 2014]; root of context hierarchy
2014-12-22 19:22:58.708 DEBUG 20816 --- [ main] ationConfigEmbeddedWebApplicationContext : Bean factory for org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@ddd51a7: org.springframework.beans.factory.support.DefaultListableBeanFactory@47649f10: defining beans [org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,main]; root of factory hierarchy
2014-12-22 19:23:00.964 INFO 20816 --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Overriding bean definition for bean 'beanNameViewResolver': replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration$WhitelabelErrorViewConfiguration; factoryMethodName=beanNameViewResolver; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/web/ErrorMvcAutoConfiguration$WhitelabelErrorViewConfiguration.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter; factoryMethodName=beanNameViewResolver; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter.class]]
2014-12-22 19:23:02.480 DEBUG 20816 --- [ main] ationConfigEmbeddedWebApplicationContext : Unable to locate MessageSource with name 'messageSource': using default [org.springframework.context.support.DelegatingMessageSource@177df6c1]
2014-12-22 19:23:02.481 DEBUG 20816 --- [ main] ationConfigEmbeddedWebApplicationContext : Using ApplicationEventMulticaster [org.springframework.context.event.SimpleApplicationEventMulticaster@4ed304f3]
2014-12-22 19:23:03.647 DEBUG 20816 --- [ main] .t.TomcatEmbeddedServletContainerFactory : Code archive: /root/spectrom-upload-service/target/upload-service-1.0-SNAPSHOT.jar
2014-12-22 19:23:03.648 DEBUG 20816 --- [ main] .t.TomcatEmbeddedServletContainerFactory : Code archive: /root/spectrom-upload-service/target/upload-service-1.0-SNAPSHOT.jar
2014-12-22 19:23:03.648 DEBUG 20816 --- [ main] .t.TomcatEmbeddedServletContainerFactory : None of the document roots [src/main/webapp, public, static] point to a directory and will be ignored.
2014-12-22 19:23:03.691 INFO 20816 --- [ main] .t.TomcatEmbeddedServletContainerFactory : Server initialized with port: 8080
2014-12-22 19:23:04.855 INFO 20816 --- [ main] o.apache.catalina.core.StandardService : Starting service Tomcat
2014-12-22 19:23:04.856 INFO 20816 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/7.0.57
2014-12-22 19:23:05.008 INFO 20816 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2014-12-22 19:23:05.009 INFO 20816 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 6326 ms
2014-12-22 19:23:06.928 INFO 20816 --- [ost-startStop-1] o.s.b.c.e.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/]
2014-12-22 19:23:06.933 INFO 20816 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
^c 之后:
^C2014-12-22 19:24:28.771 INFO 20816 --- [ Thread-2] ationConfigEmbeddedWebApplicationContext : Closing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@ddd51a7: startup date [Mon Dec 22 19:22:58 EST 2014]; root of context hierarchy
2014-12-22 19:24:28.815 WARN 20816 --- [ Thread-2] ationConfigEmbeddedWebApplicationContext : Exception thrown from LifecycleProcessor on context close
java.lang.IllegalStateException: LifecycleProcessor not initialized - call 'refresh' before invoking lifecycle methods via the context: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@ddd51a7: startup date [Mon Dec 22 19:22:58 EST 2014]; root of context hierarchy
at org.springframework.context.support.AbstractApplicationContext.getLifecycleProcessor(AbstractApplicationContext.java:359)
at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:890)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.doClose(EmbeddedWebApplicationContext.java:141)
at org.springframework.context.support.AbstractApplicationContext$1.run(AbstractApplicationContext.java:811)
挂起期间的线程转储:
2014-12-23 01:09:58
Full thread dump Java HotSpot(TM) 64-Bit Server VM (25.25-b02 mixed mode):
"localhost-startStop-1" #13 daemon prio=5 os_prio=0 tid=0x00007f56c431a800 nid=0x12 runnable [0x00007f56e0bec000]
java.lang.Thread.State: RUNNABLE
at java.io.FileInputStream.readBytes(Native Method)
at java.io.FileInputStream.read(FileInputStream.java:246)
at sun.security.provider.SeedGenerator$URLSeedGenerator.getSeedBytes(SeedGenerator.java:539)
at sun.security.provider.SeedGenerator.generateSeed(SeedGenerator.java:144)
at sun.security.provider.SecureRandom$SeederHolder.<clinit>(SecureRandom.java:203)
at sun.security.provider.SecureRandom.engineNextBytes(SecureRandom.java:221)
- locked <0x00000000f10478f8> (a sun.security.provider.SecureRandom)
at java.security.SecureRandom.nextBytes(SecureRandom.java:457)
- locked <0x00000000f1047c18> (a java.security.SecureRandom)
at java.security.SecureRandom.next(SecureRandom.java:480)
at java.util.Random.nextInt(Random.java:329)
at org.apache.catalina.util.SessionIdGenerator.createSecureRandom(SessionIdGenerator.java:246)
at org.apache.catalina.util.SessionIdGenerator.getRandomBytes(SessionIdGenerator.java:183)
at org.apache.catalina.util.SessionIdGenerator.generateSessionId(SessionIdGenerator.java:153)
at org.apache.catalina.session.ManagerBase.startInternal(ManagerBase.java:573)
at org.apache.catalina.session.StandardManager.startInternal(StandardManager.java:485)
- locked <0x00000000f0fa82e0> (a org.apache.catalina.session.StandardManager)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
- locked <0x00000000f0fa82e0> (a org.apache.catalina.session.StandardManager)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5501)
- locked <0x00000000f68e5d68> (a org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedContext)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
- locked <0x00000000f68e5d68> (a org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedContext)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1575)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1565)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
"Tomcat-startStop-1" #12 daemon prio=5 os_prio=0 tid=0x00007f56c8405000 nid=0x11 waiting on condition [0x00007f56f4103000]
java.lang.Thread.State: WAITING (parking)
at sun.misc.Unsafe.park(Native Method)
- parking to wait for <0x00000000f69aa980> (a java.util.concurrent.FutureTask)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:175)
at java.util.concurrent.FutureTask.awaitDone(FutureTask.java:429)
at java.util.concurrent.FutureTask.get(FutureTask.java:191)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1123)
- locked <0x00000000f68505c0> (a org.apache.catalina.core.StandardHost)
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:816)
- locked <0x00000000f68505c0> (a org.apache.catalina.core.StandardHost)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
- locked <0x00000000f68505c0> (a org.apache.catalina.core.StandardHost)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1575)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1565)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
"DestroyJavaVM" #10 prio=5 os_prio=0 tid=0x00007f56f0009800 nid=0x7 waiting on condition [0x0000000000000000]
java.lang.Thread.State: RUNNABLE
"main" #9 prio=5 os_prio=0 tid=0x00007f56f0159800 nid=0x10 waiting on condition [0x00007f56f4cf0000]
java.lang.Thread.State: WAITING (parking)
at sun.misc.Unsafe.park(Native Method)
- parking to wait for <0x00000000f69aac08> (a java.util.concurrent.FutureTask)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:175)
at java.util.concurrent.FutureTask.awaitDone(FutureTask.java:429)
at java.util.concurrent.FutureTask.get(FutureTask.java:191)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1123)
- locked <0x00000000f68d1648> (a org.apache.catalina.core.StandardEngine)
at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:300)
- locked <0x00000000f68d1648> (a org.apache.catalina.core.StandardEngine)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
- locked <0x00000000f68d1648> (a org.apache.catalina.core.StandardEngine)
at org.apache.catalina.core.StandardService.startInternal(StandardService.java:443)
- locked <0x00000000f68d1648> (a org.apache.catalina.core.StandardEngine)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
- locked <0x00000000f6850418> (a org.apache.catalina.core.StandardService)
at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:739)
- locked <0x00000000f6850590> (a [Lorg.apache.catalina.Service;)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
- locked <0x00000000f683f5d8> (a org.apache.catalina.core.StandardServer)
at org.apache.catalina.startup.Tomcat.start(Tomcat.java:341)
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.initialize(TomcatEmbeddedServletContainer.java:85)
- locked <0x00000000f68c4660> (a org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer)
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.<init>(TomcatEmbeddedServletContainer.java:74)
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.getTomcatEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:377)
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.getEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:153)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:148)
- locked <0x00000000f5dd9708> (a org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:121)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:476)
- locked <0x00000000f5de2550> (a java.lang.Object)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:109)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:691)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:320)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:952)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:941)
at com.spectrom.uploadService.Main.main(Main.java:17)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:53)
at java.lang.Thread.run(Thread.java:745)
"Service Thread" #7 daemon prio=9 os_prio=0 tid=0x00007f56f00cd000 nid=0xe runnable [0x0000000000000000]
java.lang.Thread.State: RUNNABLE
"C1 CompilerThread1" #6 daemon prio=9 os_prio=0 tid=0x00007f56f00ca000 nid=0xd waiting on condition [0x0000000000000000]
java.lang.Thread.State: RUNNABLE
"C2 CompilerThread0" #5 daemon prio=9 os_prio=0 tid=0x00007f56f00c8000 nid=0xc waiting on condition [0x0000000000000000]
java.lang.Thread.State: RUNNABLE
"Signal Dispatcher" #4 daemon prio=9 os_prio=0 tid=0x00007f56f00c6000 nid=0xb waiting on condition [0x0000000000000000]
java.lang.Thread.State: RUNNABLE
"Finalizer" #3 daemon prio=8 os_prio=0 tid=0x00007f56f009a000 nid=0xa in Object.wait() [0x00007f56f5500000]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x00000000f5bb8068> (a java.lang.ref.ReferenceQueue$Lock)
at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:142)
- locked <0x00000000f5bb8068> (a java.lang.ref.ReferenceQueue$Lock)
at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:158)
at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:209)
"Reference Handler" #2 daemon prio=10 os_prio=0 tid=0x00007f56f0097800 nid=0x9 in Object.wait() [0x00007f56f5601000]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x00000000f5bb8220> (a java.lang.ref.Reference$Lock)
at java.lang.Object.wait(Object.java:502)
at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:157)
- locked <0x00000000f5bb8220> (a java.lang.ref.Reference$Lock)
"VM Thread" os_prio=0 tid=0x00007f56f0090800 nid=0x8 runnable
"VM Periodic Task Thread" os_prio=0 tid=0x00007f56f00dc800 nid=0xf waiting on condition
JNI global references: 29
Heap
def new generation total 13696K, used 12232K [0x00000000f0600000, 0x00000000f14d0000, 0x00000000f5950000)
eden space 12224K, 88% used [0x00000000f0600000, 0x00000000f1082050, 0x00000000f11f0000)
from space 1472K, 100% used [0x00000000f11f0000, 0x00000000f1360000, 0x00000000f1360000)
to space 1472K, 0% used [0x00000000f1360000, 0x00000000f1360000, 0x00000000f14d0000)
tenured generation total 30240K, used 20916K [0x00000000f5950000, 0x00000000f76d8000, 0x0000000100000000)
the space 30240K, 69% used [0x00000000f5950000, 0x00000000f6dbd1b0, 0x00000000f6dbd200, 0x00000000f76d8000)
Metaspace used 23431K, capacity 23620K, committed 23728K, reserved 1071104K
class space used 2909K, capacity 2974K, committed 2992K, reserved 1048576K
最佳答案
知道了!在主机上安装 haveged 后,该过程立即向前推进,并且 Spring 启动正常。一旦我对 docker 如何与主机上的 haveged 交互进行更多研究,我将发布更多信息。
总而言之,在主机上发出的以下命令将解决该问题:
apt-get install haveged -y
如果有人对此有详细了解,欢迎留言!
目前我不明白的是,为什么主机需要额外的代码,而所有东西都没有隔离在 docker 容器中。
关于java - Spring-boot 应用程序不会在 docker 内启动时启动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27612209/
我需要在客户计算机上运行Ruby应用程序。通常需要几天才能完成(复制大备份文件)。问题是如果启用sleep,它会中断应用程序。否则,计算机将持续运行数周,直到我下次访问为止。有什么方法可以防止执行期间休眠并让Windows在执行后休眠吗?欢迎任何疯狂的想法;-) 最佳答案 Here建议使用SetThreadExecutionStateWinAPI函数,使应用程序能够通知系统它正在使用中,从而防止系统在应用程序运行时进入休眠状态或关闭显示。像这样的东西:require'Win32API'ES_AWAYMODE_REQUIRED=0x0
对于具有离线功能的智能手机应用程序,我正在为Xml文件创建单向文本同步。我希望我的服务器将增量/差异(例如GNU差异补丁)发送到目标设备。这是计划:Time=0Server:hasversion_1ofXmlfile(~800kiB)Client:hasversion_1ofXmlfile(~800kiB)Time=1Server:hasversion_1andversion_2ofXmlfile(each~800kiB)computesdeltaoftheseversions(=patch)(~10kiB)sendspatchtoClient(~10kiBtransferred)Cl
Rackup通过Rack的默认处理程序成功运行任何Rack应用程序。例如:classRackAppdefcall(environment)['200',{'Content-Type'=>'text/html'},["Helloworld"]]endendrunRackApp.new但是当最后一行更改为使用Rack的内置CGI处理程序时,rackup给出“NoMethodErrorat/undefinedmethod`call'fornil:NilClass”:Rack::Handler::CGI.runRackApp.newRack的其他内置处理程序也提出了同样的反对意见。例如Rack
我想用ruby编写一个小的命令行实用程序并将其作为gem分发。我知道安装后,Guard、Sass和Thor等某些gem可以从命令行自行运行。为了让gem像二进制文件一样可用,我需要在我的gemspec中指定什么。 最佳答案 Gem::Specification.newdo|s|...s.executable='name_of_executable'...endhttp://docs.rubygems.org/read/chapter/20 关于ruby-在Ruby中编写命令行实用程序
我构建了两个需要相互通信和发送文件的Rails应用程序。例如,一个Rails应用程序会发送请求以查看其他应用程序数据库中的表。然后另一个应用程序将呈现该表的json并将其发回。我还希望一个应用程序将存储在其公共(public)目录中的文本文件发送到另一个应用程序的公共(public)目录。我从来没有做过这样的事情,所以我什至不知道从哪里开始。任何帮助,将不胜感激。谢谢! 最佳答案 无论Rails是什么,几乎所有Web应用程序都有您的要求,大多数现代Web应用程序都需要相互通信。但是有一个小小的理解需要你坚持下去,网站不应直接访问彼此
我尝试运行2.x应用程序。我使用rvm并为此应用程序设置其他版本的ruby:$rvmuseree-1.8.7-head我尝试运行服务器,然后出现很多错误:$script/serverNOTE:Gem.source_indexisdeprecated,useSpecification.Itwillberemovedonorafter2011-11-01.Gem.source_indexcalledfrom/Users/serg/rails_projects_terminal/work_proj/spohelp/config/../vendor/rails/railties/lib/r
设置:狂欢ruby1.9.2高线(1.6.13)描述:我已经相当习惯在其他一些项目中使用highline,但已经有几个月没有使用它了。现在,在Ruby1.9.2上全新安装时,它似乎不允许在同一行回答提示。所以以前我会看到类似的东西:require"highline/import"ask"Whatisyourfavoritecolor?"并得到:Whatisyourfavoritecolor?|现在我看到类似的东西:Whatisyourfavoritecolor?|竖线(|)符号是我的终端光标。知道为什么会发生这种变化吗? 最佳答案
刚入门rails,开始慢慢理解。有人可以解释或给我一些关于在application_controller中编码的好处或时间和原因的想法吗?有哪些用例。您如何为Rails应用程序使用应用程序Controller?我不想在那里放太多代码,因为据我了解,每个请求都会调用此Controller。这是真的? 最佳答案 ApplicationController实际上是您应用程序中的每个其他Controller都将从中继承的类(尽管这不是强制性的)。我同意不要用太多代码弄乱它并保持干净整洁的态度,尽管在某些情况下ApplicationContr
我在我的Rails项目中使用Pow和powifygem。现在我尝试升级我的ruby版本(从1.9.3到2.0.0,我使用RVM)当我切换ruby版本、安装所有gem依赖项时,我通过运行railss并访问localhost:3000确保该应用程序正常运行以前,我通过使用pow访问http://my_app.dev来浏览我的应用程序。升级后,由于错误Bundler::RubyVersionMismatch:YourRubyversionis1.9.3,butyourGemfilespecified2.0.0,此url不起作用我尝试过的:重新创建pow应用程序重启pow服务器更新战俘
我真的很习惯使用Ruby编写以下代码:my_hash={}my_hash['test']=1Java中对应的数据结构是什么? 最佳答案 HashMapmap=newHashMap();map.put("test",1);我假设? 关于java-等价于Java中的RubyHash,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/22737685/