访问 websphere 8 shareLib 路径 frim Spring java 代码
accessing websphere 8 shareLib path frim Spring java code
我正在制作一个 Spring 4.1.4 REST 服务并将其部署到我本地的 websphere 应用程序服务器 8 Windows 7.
我创建了一个共享库,如下所示,并将其引用到受人尊敬的 war 文件
sharedLib configuration
在那个位置,我将 属性 文件保存为 /abc/application.properties
loaction of the abc folder in APPSERVER
代码:
我正在尝试加载 spring-rest.xml
中的文件
<bean id="fileSystemResource" class="org.springframework.core.io.FileSystemResource">
<constructor-arg value="#{systemProperties['sharedLib']}/abc/">
</constructor-arg>
</bean>
<bean id="propertyLoader" name="propertyLoader" class="com.framework.RuntimeEnvironmentPropertiesConfigurer">
<property name="propertyLocation" ref="fileSystemResource" />
</bean>
我的 属性loader class:which 工作正常 :::
public class RuntimeEnvironmentPropertiesConfigurer extends PropertyPlaceholderConfigurer implements InitializingBean,RuntimeEnvironmentInterface {
/** The Environment */
public String environment;
/** The Property Location */
public FileSystemResource propertyLocation;
但很遗憾,这是在我的 C:/ 驱动器.
中搜索 abc 文件夹
如果我在 C:/abc/application.properties.. 中保留以下内容,那么我的应用程序属性正在变得 fetched.And 应用程序 运行 很好 所以加载 Bean 没有问题。
还在 pom.xml 中给出了我的依赖项,不确定我是否需要添加任何其他依赖项。
<properties>
<springframework.version>4.1.4.RELEASE</springframework.version>
<jackson.library>2.7.5</jackson.library>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>4.1.4.RELEASE</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>4.1.4.RELEASE</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>4.1.4.RELEASE</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>3.0.0.RELEASE</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>3.0.0.RELEASE</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.7.5</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
<version>3.8.11.2</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.9</version>
<scope>compile</scope>
<exclusions>
<exclusion>
<artifactId>mail</artifactId>
<groupId>javax.mail</groupId>
</exclusion>
<exclusion>
<artifactId>jms</artifactId>
<groupId>javax.jms</groupId>
</exclusion>
<exclusion>
<artifactId>jmxtools</artifactId>
<groupId>com.sun.jdmk</groupId>
</exclusion>
<exclusion>
<artifactId>jmxri</artifactId>
<groupId>com.sun.jmx</groupId>
</exclusion>
</exclusions>
</dependency>
但我需要从共享库位置获取路径。
谁能帮我指出我所缺少的?
请提供答案,我怎样才能在 Spring 中实现这一点。
Java WebSphere 中的系统属性来自 Application Server 的 Process Definition
> Java Virtual Machine
> Custom Properties
,而不是来自 WebSphere variables
我正在制作一个 Spring 4.1.4 REST 服务并将其部署到我本地的 websphere 应用程序服务器 8 Windows 7.
我创建了一个共享库,如下所示,并将其引用到受人尊敬的 war 文件 sharedLib configuration
在那个位置,我将 属性 文件保存为 /abc/application.properties
loaction of the abc folder in APPSERVER
代码: 我正在尝试加载 spring-rest.xml
中的文件<bean id="fileSystemResource" class="org.springframework.core.io.FileSystemResource">
<constructor-arg value="#{systemProperties['sharedLib']}/abc/">
</constructor-arg>
</bean>
<bean id="propertyLoader" name="propertyLoader" class="com.framework.RuntimeEnvironmentPropertiesConfigurer">
<property name="propertyLocation" ref="fileSystemResource" />
</bean>
我的 属性loader class:which 工作正常 :::
public class RuntimeEnvironmentPropertiesConfigurer extends PropertyPlaceholderConfigurer implements InitializingBean,RuntimeEnvironmentInterface {
/** The Environment */
public String environment;
/** The Property Location */
public FileSystemResource propertyLocation;
但很遗憾,这是在我的 C:/ 驱动器.
中搜索 abc 文件夹如果我在 C:/abc/application.properties.. 中保留以下内容,那么我的应用程序属性正在变得 fetched.And 应用程序 运行 很好 所以加载 Bean 没有问题。
还在 pom.xml 中给出了我的依赖项,不确定我是否需要添加任何其他依赖项。
<properties>
<springframework.version>4.1.4.RELEASE</springframework.version>
<jackson.library>2.7.5</jackson.library>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>4.1.4.RELEASE</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>4.1.4.RELEASE</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>4.1.4.RELEASE</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>3.0.0.RELEASE</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>3.0.0.RELEASE</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.7.5</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
<version>3.8.11.2</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.9</version>
<scope>compile</scope>
<exclusions>
<exclusion>
<artifactId>mail</artifactId>
<groupId>javax.mail</groupId>
</exclusion>
<exclusion>
<artifactId>jms</artifactId>
<groupId>javax.jms</groupId>
</exclusion>
<exclusion>
<artifactId>jmxtools</artifactId>
<groupId>com.sun.jdmk</groupId>
</exclusion>
<exclusion>
<artifactId>jmxri</artifactId>
<groupId>com.sun.jmx</groupId>
</exclusion>
</exclusions>
</dependency>
但我需要从共享库位置获取路径。 谁能帮我指出我所缺少的? 请提供答案,我怎样才能在 Spring 中实现这一点。
Java WebSphere 中的系统属性来自 Application Server 的 Process Definition
> Java Virtual Machine
> Custom Properties
,而不是来自 WebSphere variables