NutzCN Logo
问答 Gradle构建 hello word Demo 访问404
发布于 2663天前 作者 qq_32ee9e89 2237 次浏览 复制 上一个帖子 下一个帖子
标签: gradle

用maven构建的hello word 项目可以正常运行 用gradle构建的项目访问404
有没有gradle构建的简单demo?

11 回复
Error:Internal error: (java.io.FileNotFoundException) D:\workspace\build\libs\exploded\test.war\WEB-INF\web.xml (拒绝访问。)
java.io.FileNotFoundException: D:\workspace\build\libs\exploded\test.war\WEB-INF\web.xml (拒绝访问。)
	at java.io.FileOutputStream.open0(Native Method)
	at java.io.FileOutputStream.open(FileOutputStream.java:270)
	at java.io.FileOutputStream.<init>(FileOutputStream.java:213)
	at java.io.FileOutputStream.<init>(FileOutputStream.java:162)
	at com.intellij.openapi.util.io.FileUtil.openOutputStream(FileUtil.java:532)
	at com.intellij.openapi.util.io.FileUtil.performCopy(FileUtil.java:484)
	at com.intellij.openapi.util.io.FileUtil.copyContent(FileUtil.java:476)
	at org.jetbrains.jps.incremental.artifacts.instructions.FilterCopyHandler.copyFile(FilterCopyHandler.java:40)
	at org.jetbrains.jps.incremental.artifacts.instructions.FileBasedArtifactRootDescriptor.copyFromRoot(FileBasedArtifactRootDescriptor.java:100)
	at org.jetbrains.jps.incremental.artifacts.IncArtifactBuilder.build(IncArtifactBuilder.java:150)
	at org.jetbrains.jps.incremental.artifacts.IncArtifactBuilder.build(IncArtifactBuilder.java:50)
	at org.jetbrains.jps.incremental.IncProjectBuilder.buildTarget(IncProjectBuilder.java:970)
	at org.jetbrains.jps.incremental.IncProjectBuilder.runBuildersForChunk(IncProjectBuilder.java:951)
	at org.jetbrains.jps.incremental.IncProjectBuilder.buildTargetsChunk(IncProjectBuilder.java:1012)
	at org.jetbrains.jps.incremental.IncProjectBuilder.buildChunkIfAffected(IncProjectBuilder.java:903)
	at org.jetbrains.jps.incremental.IncProjectBuilder.buildChunks(IncProjectBuilder.java:736)
	at org.jetbrains.jps.incremental.IncProjectBuilder.runBuild(IncProjectBuilder.java:384)
	at org.jetbrains.jps.incremental.IncProjectBuilder.build(IncProjectBuilder.java:192)
	at org.jetbrains.jps.cmdline.BuildRunner.runBuild(BuildRunner.java:138)
	at org.jetbrains.jps.cmdline.BuildSession.runBuild(BuildSession.java:295)
	at org.jetbrains.jps.cmdline.BuildSession.run(BuildSession.java:125)
	at org.jetbrains.jps.cmdline.BuildMain$MyMessageHandler.lambda$channelRead0$0(BuildMain.java:236)
	at org.jetbrains.jps.service.impl.SharedThreadPoolImpl.lambda$executeOnPooledThread$0(SharedThreadPoolImpl.java:42)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:748)
Please perform full project rebuild (Build | Rebuild Project)

执行的命令是啥??

tomcat启动 web.xml在WEB-INF目录下,web.xml什么也没有配置,启动也是报这个错

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
         version="3.1">

</web-app>

把工程配置好以后,用IDEA启动tomcat的时候报的web.xml拒绝访问的错。

build.gradle 贴来看看

apply plugin: 'java'
apply plugin: 'war'

sourceCompatibility = 1.8

repositories {
    mavenCentral()
}

dependencies {
    testCompile group: 'junit', name: 'junit', version: '4.11'
    testCompile group: 'junit', name: 'junit', version: '4.12'
    compile group: 'org.nutz', name: 'nutz', version: '1.r.60'
    compile group: 'javax.servlet', name: 'javax.servlet-api', version: '3.1.0'
}

dependencies 里面的错误不少,但不是原因的样子.

web.xml的完整路径是 src/main/webapp/WEB-INF/web.xml 吗?

恩恩 web.xml路径跟你写得一样

可能是工程不干净,新建一个工程好了,谢谢作者一直积极帮忙解决问题。

nutz.jar是一群人持续改进的类库,并不专属于某个人 ^_^

添加回复
请先登陆
回到顶部