草庐IT

commons-lang

全部标签

java - grails spock 测试失败,显示 'java.lang.IllegalArgumentException: ServletContext must not be null'

我在commandclass中有一个方法,它使用messageSource.getMessage(...),因为messageSource不会被注入(inject)到commandClass。我用defmessageSource=Holders.applicationContext.getBean("messageSource")在commandClass中。我的问题是在尝试编写单元测试这个方法时,@Beforevoidsetup(){Holders.applicationContext.getBean("messageSource")}void"testFunction"(){//i

java.lang.OutOfMemoryError : PermGen space error with Jetty 错误

我目前收到一个java.lang.OutOfMemoryError:PermGenspace。我正在使用Jetty和LinuxUbuntu。我曾尝试阅读并尝试在之前的类似问题中提供的不同解决方案,但没有取得任何成功。一个类似的问题是Dealingwith“java.lang.OutOfMemoryError:PermGenspace”error但这些解决方案似乎使用Tomcat而不是Jetty。如果我重新部署我的服务几次,我会不断收到内存不足错误。例如,为了测试这个,我将转到我的webapps文件夹并运行touch*.xml来更新时间戳,然后重新运行jetty,我得到了内存不足错误。在

java - 我可以在 apache commons cli 中创建带有连字符的选项名称吗?

我正在尝试使用ApacheCommonsCLIjava库在其中设置带有连字符的选项名称,如“源文件”。Optionoption=newOption("source-files",true,"Listofsourcefiles")我得到这个错误,java.lang.IllegalArgumentException:optcontainsillegalcharactervalue'-'atorg.apache.commons.cli.OptionValidator.validateOption(OptionValidator.java:73)atorg.apache.commons.cli

java - 如果使用来自 Guava 的 com.google.common,为什么不应该使用 Objects.requireNonNull()?

Preconditions的Javadoc来自Google的Guava库指出:Projectswhichusecom.google.commonshouldgenerallyavoidtheuseofObjects.requireNonNull(Object).Instead,usewhicheverofcheckNotNull(Object)orVerify.verifyNotNull(Object)isappropriatetothesituation.(Thesamegoesforthemessage-acceptingoverloads.)此建议背后的动机是什么?我在Javad

java.lang.NoClassDefFoundError : org/apache/commons/lang3/ObjectUtils 错误

我正在尝试编写一个程序来读取CSV文件,然后用它制作一些东西。我搜索了很多,终于找到了this图书馆。几天前我完成了代码,一切正常。今天把库更新到4.0v,然后跳出一大堆警告。我做了一些测试,失败的部分是:publicvoidLeerCSV(FileCSVCat,FileCSVProd){//CreounobjetodelaclaseFileReaderquemehacefaltaparalosCSVReaderCSVReaderBuilderlectorCatBuilder=null;CSVReaderBuilderlectorProdBuilder=null;CSVReaderCa

java - 在向布局添加按钮时获取 java.lang.reflect.InvocationTargetException

我是javafx的新手!!我尝试了一个非常非常简单的代码,但我卡住了。当我尝试向布局添加按钮时它不起作用。我知道这个问题可能太简单了,但我真的不知道如何解决。如果你能帮助我,我将不胜感激。这是我的代码:importjavafx.application.Application;importjavafx.scene.Scene;importjavafx.scene.control.Button;importjavafx.scene.layout.StackPane;importjavafx.stage.Stage;publicclassTestextendsApplication{Butt

java - SSL 握手异常 : no cipher suites in common

按照说明进行操作here并重新创建了我之前错误创建的证书。正如我现在看到的,有些东西已经改变了javax.net.ssl.SSLHandshakeException:nociphersuitesincommon在服务器上和javax.net.ssl.SSLHandshakeException:Receivedfatalalert:handshake_failure在客户端上。而不是错误thisquestion服务器是ClassFileServer.java和各自的客户SSLSocketClientWithClientAuth.java关于让两端很好地发挥作用的任何提示,请注意,我使用的

java.lang.NoClassDefFoundError : org/apache/commons/pool/impl/GenericObjectPool 错误

我正在尝试使用tomcat6和postgresql在tomcat项目下的web.xml中将org.apache.commons.dbcp.BasicDataSource配置为bean9.1我的servletdispacher.xml`DAOModel.Tblusersorg.hibernate.dialect.PostgreSQLDialectorg.hibernate.transaction.JDBCTransactionFactorytrueupdate`和错误得到:javax.servlet.ServletException:Servlet.init()forservletdis

java.lang.NoSuchMethodError : javaxservlet. http.HttpServletRequest.isAsyncStarted()Z

我正在尝试使用JUnit和Mockito针对我正在构建的springRESTweb服务运行测试。我在尝试运行JUnit测试时遇到了一个错误,但找不到有关该问题的任何信息。堆栈跟踪将错误行列为.andDo(print())尽管我直接从spring.io教程中获得了该行http://spring.io/guides/tutorials/rest/3/测试类代码:publicclassTestSuite{MockMvcmockMvc;@MockRestControllercontroller;@Beforepublicvoidsetup(){MockitoAnnotations.initMo

java.lang.NoSuchMethodError : com. sun.mail.util.TraceInputStream

我正在尝试通过JavaMailAPI发送电子邮件,它在我的笔记本电脑上运行良好。当我在Heroku中做同样的事情时,我得到了这个:java.lang.NoSuchMethodError:com.sun.mail.util.TraceInputStream.(Ljava/io/InputStream;Lcom/sun/mail/util/MailLogger;)Vatcom.sun.mail.smtp.SMTPTransport.initStreams(SMTPTransport.java:2014)atcom.sun.mail.smtp.SMTPTransport.openServer