草庐IT

environment_variables

全部标签

java - 获取 Apache-Tomcat 的错误 :JRE_HOME variable is not defined correctly when trying to run startup. bat

已结束。此问题需要debuggingdetails.它目前不接受答案。编辑问题以包含desiredbehavior,aspecificproblemorerror,andtheshortestcodenecessarytoreproducetheproblem.这将有助于其他人回答问题。关闭7年前。Improvethisquestion当尝试使用'startup.bat'通过cmd提示符启动Tomcat服务器时,出现错误为-“未正确定义JRE_HOME变量。运行此程序需要环境变量”定义环境路径为-CATALINA_HOME-C:\ProgramFiles\Java\apache-tom

java - 哪个更有效: if (null == variable) or if (variable == null)?

这个问题在这里已经有了答案:'...!=null'or'null!=....'bestperformance?(16个答案)关闭6年前.在Java中,哪个会更有效,有什么区别?if(null==variable)或if(variable==null) 最佳答案 (类似于这个问题:Differencebetweennull==objectandobject==null)我会说这两个表达式在性能上绝对没有区别。然而,有趣的是,编译后的字节码(由OpenJDKsjavac发出)在这两种情况下看起来有点不同。对于booleanb=varia

java - 在 IntelliJ IDEA 中抑制 "variable is never assigned"警告

我们在代码中广泛使用反射来设置类字段值。这些字段是在代码中访问的,但除了通过反射之外,它们永远不会被分配。因此IDEA显示“从未分配”警告。如果我要求IDEA禁止检查,它会插入@SuppressWarnings({"UnusedDeclaration"})但这也禁用了对该字段是否被使用的检查,这是我们不想要的。是否可以仅禁用“未分配”检查并仅对特定字段保留“未使用”检查?IDEA版本为10.5 最佳答案 您可以使用注释将其标记为注入(inject)字段。(类似于它对待@EJB的方式)。IntelliJ检查(至少在10.5版中)允许您

java - variable = null 是否将其设置为垃圾收集

帮我解决与同事的纠纷:在Java中将变量或集合设置为null是否有助于垃圾收集和减少内存使用?如果我有一个长时间运行的程序并且每个函数都可能被迭代调用(可能数千次):在将值返回给父函数之前将其中的所有变量设置为null是否有助于减少堆大小/内存使用? 最佳答案 这是旧的表演知识。早在1.0天就是这样,但是编译器和JVM已经过改进以消除这种需要(如果有的话)。如果您有兴趣,这篇出色的IBM文章会详细介绍:Javatheoryandpractice:Garbagecollectionandperformance

java - Spring 3.1配置: environment not injected

我在spring3.1配置中使用以下内容:@Configuration@EnableTransactionManagementpublicclassDataConfig{@InjectprivateEnvironmentenv;@InjectprivateDataSourcedataSource;//@BeanpublicSpringLiquibaseliquibase(){SpringLiquibaseb=newSpringLiquibase();b.setDataSource(dataSource);b.setChangeLog("classpath:META-INF/db-cha

spring - @Value 注解和 Environment API 的区别?

使用@Value注解注入(inject)类的字段和使用SpringEnvironmentAPI查找它们之间是否存在显着差异?一个比另一个更可取(以及在什么情况下)?使用@Value的示例:classConfig{@Value("${db.driverClassName}")privateStringdriverClassName;@Value("${db.url}")privateStringurl;@Value("${db.username}")privateStringusername;@Value("${db.password}")privateStringpassword;@B

java - 有没有像 : #{systemProperties ['environment_variable_name' ]} to get the system variable? 这样的语法

在Spring的applicationcontext.xml文件中使用#{systemProperties['environment']}是否返回与环境关联的值?或者有什么办法可以在springapplicationcontext.xml文件中获取系统变量值。 最佳答案 当我没记错的时候,有区别:您可以通过不同的方式访问系统属性:#{systemProperties['databaseName']}#{systemProperties.databaseName}${databaseName}//$而不是#!!与#{systemPro

java - 在xml中定义Spring @PropertySource 并在Environment中使用

在springJavaConfig中,我可以定义属性源并注入(inject)到环境中@PropertySource("classpath:application.properties")@InjectprivateEnvironmentenvironment;如果在xml中,我该怎么做?我正在使用context:property-placeholder,并在JavaConfig类@ImportResource上导入xml。但我无法使用environment.getProperty("xx")检索属性文件中定义的属性 最佳答案 AFA

Spring MVC 3 : How to get path variable in an interceptor?

在SpringMVCController中,我可以使用@PathVariable获取路径变量,以获取在@RequestMapping中定义的变量的值。如何在拦截器中获取变量的值?非常感谢! 最佳答案 Pao链接的帖子对我很有帮助在preHandle()方法中,您可以通过运行以下代码来提取各种PathVariablesMappathVariables=(Map)request.getAttribute(HandlerMapping.URI_TEMPLATE_VARIABLES_ATTRIBUTE);

java - Spring Web MVC : Use same request mapping for request parameter and path variable

有没有办法表示我的SpringWebMVCController方法应该通过将ID作为URI路径的一部分提交的请求来匹配...@RequestMapping(method=RequestMethod.GET,value="campaigns/{id}")publicStringgetCampaignDetails(Modelmodel,@PathVariable("id")Longid){...或者如果客户端将ID作为HTTP请求参数以样式发送...@RequestMapping(method=RequestMethod.GET,value="campaigns")publicStrin