当我正在使用的第三方库尝试访问文件时,我收到"错误打开...文件...(没有这样的文件或目录)",即使我知道该文件在WAR中.我已经尝试了打包(.war)和"爆炸"(目录)部署,文件肯定在那里.我也尝试过设置完全权限.它是在Unix(Ubuntu)上.文件是war/dict/index.sense,错误是"dict/index.sense(没有这样的文件或目录)".
当它作为来自Eclipse的GWT应用程序在托管模式下运行时,它在我的Windows计算机上运行正常,而不是在我将其传输到Unix机器进行部署时.
我的问题是:有没有人经历过这个和/或我应该考虑相对路径的差异,即在战争中相对文件访问的根路径是什么?
我有一个Java Web应用程序.在WAR内部,我有一个包含应用程序配置文件的文件夹.我需要知道文件夹的路径,以便在运行时加载文件.
我还需要解决方案在Tomcat和WebSphere中工作.
谢谢.
我在Eclipse中有两个Maven项目,都有自己的POM.
项目A创建一个JAR文件.
项目B创建一个WAR文件.
当我对项目B运行"package"命令时,我希望它也打包项目A,然后将生成的JAR文件复制到项目B中的任意位置.
我通过使用maven-war-plugin中的webResources值尝试(并成功)了副本,如下所示:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<webResources>
<resource>
<directory>../ProjectA/target</directory>
<targetPath>.</targetPath>
<includes>
<include>ProjectA*.jar</include>
</includes>
<excludes>
<exclude>*shaded*.jar</exclude>
</excludes>
</resource>
</webResources>
Run Code Online (Sandbox Code Playgroud)
但是,如何让项目B的POM进行项目A的构建?
我尝试的另一种方法是使项目A成为项目B的依赖项,因此它将被导入到WAR的WEB-INF/lib目录中,然后将其移动到其他位置.但这似乎有点凌乱.
任何帮助,非常感谢.
我正在努力建立一个战争项目.并在编译它给我这个错误:
[编译:编译]将432个源文件编译为C:\ Beta\ECORP5\ECORP5-web\target\classes -------------------------- -----------------------------------编译错误:------------ -------------------------------------------------\Beta\fin\fin-web\src\main\java\com\comp\fin\utils\Formatter.java:[23,-1]无法访问javax.annotation.PostConstruct坏类文件:C:\ Beta\fin\fin-web\target\endorsed\javaee-endorsed-api-6.0.jar(javax/annotation/PostConstruct.class)类文件有错误的版本50.0,应该是49.0 1错误
我无法摆脱这个错误.我正在使用java 6和jdk 1.5这里是我的POM.xml或其中的一部分没有不相关的东西:
> <**?**xml version="1.0" encoding="UTF-8"?**> <**project
> xmlns="http://maven.apache.org/POM/4.0.0"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
> http://maven.apache.org/xsd/maven-4.0.0.xsd"**>
>
><*modelVersion>4.0.0<*/modelVersion>
> <*parent>
> <*artifactId>fin<*/artifactId>
> <*groupId>com.comps<*/groupId>
> <*version>1.0-SNAPSHOT<*/version>
> <*/parent>
>
> <groupId>com.comps</groupId>
> <artifactId>fin-web</artifactId>
> <version>1.0-SNAPSHOT</version>
> <packaging>war</packaging>
>
> <name>fin-web</name>
>
> <properties>
> <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
> </properties>
>
> <dependencies>
>
> <dependency>
> <groupId>javax</groupId>
> <artifactId>javaee-web-api</artifactId>
> **<version>6.0</version>**
> </dependency>
>
> </dependencies>
>
> <build>
> <plugins>
> …
Run Code Online (Sandbox Code Playgroud) 我为我的web应用程序创建了一个war文件.我在Tomcat上部署了它,它运行正常.我的问题是,如果我有3个jsp文件,如index.jsp,one.jsp,two.jsp,如果我想在运行war文件时先运行one.jsp(而不是index.jsp),该怎么办?目前index.jsp主要运行.我正在使用netbeans,netbeans中有没有选项???
我将war文件转换为zip文件以进行一些自定义.重命名它将其显示为war文件,但在属性中具有zip图标和zip扩展名.如何将zip文件转换回war文件?
我想用war文件中的最小化版本(由Closure Compiler最小化 - https://developers.google.com/closure/compiler/docs/gettingstarted_app)替换js 文件.为了建立战争,我正在使用蚂蚁:
...
<target name="war" depends="buildnumber" description="--> Creates a WAR of a Grails application">
<grails command="war" environment="${grails.env}"/>
</target>
...
Run Code Online (Sandbox Code Playgroud)
我补充说:
grails.project.resources = { stagingDir ->
delete(file:"${stagingDir}/js/*.js")
}
Run Code Online (Sandbox Code Playgroud)
到<root>\grails-app\conf\BuildConfig.groovy但是没有删除war文件的js文件.
如何在ant构建文件中提供最小化的文件列表,以及如何将其添加到最终war文件中?
更新:
我在\ grails-app\conf\BuildConfig.groovy中添加了以下内容,将最小化的文件复制到war文件中.在第一步中,ant最小化js文件.在下一步中生成war文件,此步骤用最小化文件替换原始js文件.
grails.war.resources = { stagingDir, args ->
def jsFiles = [
'file1.js',
'file2.js',
'file3.js',
...
'templates.common.js'
];
for (file in jsFiles) {
File f = new File("minimizedjs\\${file}");
if(f.exists()) {
copy(file: "minimizedjs\\${file}", tofile: "${stagingDir}\\js\\${file}")
}
else {
println('.....!');
break;
}
}
}
Run Code Online (Sandbox Code Playgroud) 从使用Maven构建Spring项目迁移到使用gradle构建它之后,我发现了奇怪的空验证错误.
我注意到该路径src/main/webapp/WEB-INF/classes
位于Web App Libraries
构建路径组下,但是使用Maven-import配置它只是在src目录中.
使用gradle cleanEclipse
,清爽和结算项目,也没有删除所有.metadata
,.settings
,bin
,.classpath
,.project
目录没有帮助.
除了WAR文件建立得很好.
组态:
//----------------------------------------------------------------------------
// SERVER'S TASKS' CONFIGURATION
//----------------------------------------------------------------------------
configure(serverProjects) {
apply plugin : 'war'
apply plugin : 'eclipse-wtp'
sourceCompatibility = 1.7
targetCompatibility = 1.7
}
project(':Server') {
war {
destinationDir serverDir
}
}
...
//----------------------------------------------------------------------------
// SERVER'S PROJECTS' CONFIGURATION
//----------------------------------------------------------------------------
project(':Server') {
eclipse {
project {
natures "com.springsource.sts.gradle.core.nature"
}
classpath {
containers "com.springsource.sts.gradle.classpathcontainer"
}
}
}
...
//---------------------------------------------------------------------------- …
Run Code Online (Sandbox Code Playgroud) 在尝试从疯狂复杂的ant构建迁移到gradle的持续传奇中 - 我正在生成一些用于'javahelp'的资源jar文件.它们不包含任何类.我需要将创建这些资源jar的项目的输出添加到我的战争的根源(而不是WEB-INF/lib
).
我试图解决的问题
apply plugin: 'war'
//Move files into position for the mmplEar project
task stage(overwrite: true, dependsOn: war) << {
}
war {
from project(':help:schedwincli').buildDir.absolutePath + '/libs'
include '*.jar'
}
dependencies {
//Ensure the jar is generated, but we don't want it in the lib dir
providedCompile project(':help:schedwincli')
}
Run Code Online (Sandbox Code Playgroud)
这会编译并运行,并且:help:schedwincli
会运行并生成所需的jar,但是当我打开我的war文件时,预期的jar不会出现在战争的任何地方.建议?
编辑
我在下面提出了Peter建议的更改,但现在我收到此错误:
无法在配置容器上找到属性"资源".
这就是它说失败的地方:
from '../../runtime', /*Fails on this line*/
'../../runtime/html',
'../../runtime/html/Jboss',
'../../runtime/props',
'../../runtime/props/Jboss',
'../../scripts',
'../../../proj/runtime',
'../../../proj/runtime/html',
'../../../proj/runtime/html/Jboss',
'../../../proj/runtime/props',
'../../../proj/runtime/props/Jboss',
configurations.resources
include …
Run Code Online (Sandbox Code Playgroud) 在tomcat中是否有任何配置,我可以在其中提及在tomcat重新启动时同时启动所有应用程序。这是为了避免在tomcat重新启动期间出现延迟。