Apache Tomcat环境变量(Apache Tomcat Environment Variables)
当我从我的IDE将我的.war文件部署到Tomcat时,我定义了:
-Dsolr.solr.home=/home/vicita/Desktop/lucene-solr/solr/solr_h -Dsolr.data.dir=/home/vicita/Desktop/lucene-solr/solr/solr_h/data
但是当我将它部署到远程机器时,我必须定义这些参数。 我遵循的书说我必须在xml文件中将其定义为$ TOMCAT_HOME / conf / Catalina / localhost:
<Context path="/solr" docBase="/usr/share/tomcat/webapps/solr.war" debug="0" crossContext="true"> <Environment name="solr/home" type="java.lang.String" value="/usr/share/solr_h/" override="true"/> </Context>
顺便一提:
/usr/share/solr_h
是我应该提及的目录。 我想知道的第一件事我没有在这里定义像solr.solr.home这样的变量?
我的.war无法找到该文件夹并抛出错误的第二件事。 我试图创建setenv.sh并放入:
-Dsolr.solr.home=/usr/share/solr_h -Dsolr.data.dir=/usr/share/solr_h/data
但是当Tomcat启动它时说:
/usr/share/tomcat/bin/setenv.sh: line 1: -Dsolr.solr.home=/usr/share/solr_h: No such file or directory /usr/share/tomcat/bin/setenv.sh: line 2: -Dsolr.data.dir=/usr/share/solr_h/data: No such file or directory Using CATALINA_BASE: /usr/share/tomcat Using CATALINA_HOME: /usr/share/tomcat Using CATALINA_TMPDIR: /usr/share/tomcat/temp Using JRE_HOME: /usr/java/default Using CLASSPATH: /usr/share/tomcat/bin/bootstrap.jar:/usr/share/tomcat/bin/tomcat-juli.jar
有什么想法来解决它吗?
When I deploy my .war file into Tomcat from my IDE I define that:
-Dsolr.solr.home=/home/vicita/Desktop/lucene-solr/solr/solr_h -Dsolr.data.dir=/home/vicita/Desktop/lucene-solr/solr/solr_h/data
However when I deploy it into a remote machine I have to define that parameters. The book that I follow says that I have to define that into $TOMCAT_HOME/conf/Catalina/localhost within an xml file:
<Context path="/solr" docBase="/usr/share/tomcat/webapps/solr.war" debug="0" crossContext="true"> <Environment name="solr/home" type="java.lang.String" value="/usr/share/solr_h/" override="true"/> </Context>
by the way:
/usr/share/solr_h
is my directory that I should mention. The first thing that I want to know I didn't define a variable like solr.solr.home at here?
Second thing that my .war could not find that folder and throws error. I tried to create setenv.sh and put:
-Dsolr.solr.home=/usr/share/solr_h -Dsolr.data.dir=/usr/share/solr_h/data
However when Tomcat starts it says:
/usr/share/tomcat/bin/setenv.sh: line 1: -Dsolr.solr.home=/usr/share/solr_h: No such file or directory /usr/share/tomcat/bin/setenv.sh: line 2: -Dsolr.data.dir=/usr/share/solr_h/data: No such file or directory Using CATALINA_BASE: /usr/share/tomcat Using CATALINA_HOME: /usr/share/tomcat Using CATALINA_TMPDIR: /usr/share/tomcat/temp Using JRE_HOME: /usr/java/default Using CLASSPATH: /usr/share/tomcat/bin/bootstrap.jar:/usr/share/tomcat/bin/tomcat-juli.jar
Any ideas to fix it?
原文:https://stackoverflow.com/questions/15626272
最满意答案
您需要实例化类本身,而不是
InsertDB()
方法。 您可以使用关键字new
来实例化一个类。 您可以参考oracle / sun 文档的官方教程。例:
Testingground myObject = new Testingground(); myObject.InsertDB(constants[i], variables[i], ticker[i], count);
方法也可以声明为
static
。 在这种情况下,您可以直接引用它们,即。Testingground.InsertDB(constants[i], variables[i], ticker[i], count);
没有构造该类的对象。同样按照惯例,方法名称是驼峰式的。 在此处阅读有关Java命名约定的更多信息。
You need to instantiate the class itself, not the method
InsertDB()
. You instantiate a class by using the key wordnew
. You can refer to the official tutorial on the oracle/sun docs.Example:
Testingground myObject = new Testingground(); myObject.InsertDB(constants[i], variables[i], ticker[i], count);
Methods can also be declared as
static
. In that case you can reference them directly ie.Testingground.InsertDB(constants[i], variables[i], ticker[i], count);
without constructing an object for that class.Also by convention method names are camel cased. Read more about naming conventions in java here.
相关问答
更多-
你不能调用不存在的东西。 由于您尚未创建对象,所以非静态方法尚不存在。 始终存在静态方法(按定义)。 You can't call something that doesn't exist. Since you haven't created an object, the non-static method doesn't exist yet. A static method (by definition) always exists.
-
你需要改变 KeyFactory.generatePublic(...) 成为: keyFactory.generatePublic(...) 目前,您的代码尝试调用generatePublic方法,就好像它是静态的(即与KeyFactory类相关联,而不是与该类型的对象相关联)。 您需要在类的特定实例上调用此方法 - 可能是您的第一个代码段中keyFactory对象。 You need to change KeyFactory.generatePublic(...) to be: keyFactor ...
-
真正的解决方 不要在main()方法中放入太多东西。 这是为了新手。 Java是一种面向对象的语言。 将逻辑放在与GarageComm类关联的方法中。 main()应该只是实例化一个实例并调用它的方法。 像这样改变它: GarageComm gc = new GarageComm(); hashPos= gc.readPositions("holdingsBU.txt");//the error is here Real solution? Don't pu ...
-
FrameLayout是一个类。 当您调用FrameLayout.setBackground()您试图在FrameLayout类本身上调用一个名为setBackground()的静态方法。 此错误告诉您这样的静态方法不存在。 你真正想要做的是在FrameLayout的特定实例上调用setBackground()方法。 首先,您需要获取对FrameLayout的引用(通常通过调用findViewById() ,然后在其上调用setBackground() 。 FrameLayout is a class. W ...
-
您需要实例化类本身,而不是InsertDB()方法。 您可以使用关键字new来实例化一个类。 您可以参考oracle / sun 文档的官方教程。 例: Testingground myObject = new Testingground(); myObject.InsertDB(constants[i], variables[i], ticker[i], count); 方法也可以声明为static 。 在这种情况下,您可以直接引用它们,即。 Testingground.InsertDB(constan ...
-
你的错误说明了一切。 只需改变这一行: ActionBar.setDisplayHomeAsUpEnabled(true); 至 theActionBar.setDisplayHomeAsUpEnabled(true); 或者只是将代码更改为如下所示: if(getSupportActionBar() != null) getSupportActionBar().setDisplayHomeAsUpEnabled(true); Your error says it all. Just change t ...
-
Android:非静态方法不能从静态上下文中引用。(Android: Non-static method cannot be referenced from static context. Confused?)[2022-12-06]
在静态上下文中,没有对象(类的实例),但实例变量和方法依赖于它们。 你有一个名为output1的实例,但你试图通过类的名字(这是一种静态方法)调用你的方法'setText'。 改变你的线条 EditText output1 = (EditText)findViewById(R.id.output); EditText.setText(result); 至 EditText output1 = (EditText)findViewById(R.id.output); output1.setT ... -
尝试成为这样的static方法: private static int divisor(int num){ return number; } 或者实例Testcase类的对象: Testcase tsc = new Testcase(); div = tsc.divisor(number); Try to become a static method like this: private static int divisor(int num){ return numbe ...
-
无法从静态上下文引用非静态方法toString()(non-static method toString() cannot be referenced from a static context)[2023-09-23]
您不应该尝试在Room类上调用toString() ,而是在Room 对象上调用 。 在该方法中,使用for循环遍历房间数组,并通过调用toString()为数组中保存的每个Room对象打印返回的String,因为这是您的方法应该执行的操作。 例如 System.out.println("All Foos held here include: "); // using a "for-each" loop, assuming an array called fooArray that holds Foo o ... -
改变你的for循环 for (Noten note : notes123){ System.out.println(Noten.notenInfo()); } 至 for (Noten note : notes123){ note.notenInfo(); } 由于noteInfo方法被定义为非静态方法,因此您尝试使用Noten(类)静态访问它。 您只能在已存在于arraylist中的引用的对象上访问它。 Change your for loop from for (Noten note : ...