- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想构建一个WAR文件(然后将其部署到Tomcat)。因此,作为练习,我在IDEA IntelliJ中使用Gradle启动了一个新的Spring Boot项目。之后,我将插件应用在build.gradle
文件中,例如apply plugin: 'war'
。
问题是,当我尝试在终端中运行gradle war
时,没有收到war文件!唯一发生的是它将生成一个带有3个子焊料\build
,classes
和resources
的tmp
,但是其中没有WAR。
我应该怎么做才能获得WAR文件?我看过this视频,但是这个人使用Maven,并且不做任何高级工作而是打仗。我认为必须有一种使其保持简单的方法。
当我运行gradle war --info
Initialized native services in: C:\Users\...\.gradle\native The client
...
Task :compileJava UP-TO-DATE Resolving global dependency management for project 'deleteme' Excluding [org.apache.tomcat:tomcat-annotations-api] Excluding [] Skipping task ':compileJava' as it is up-to-date. :compileJava (Thread[Task worker for ':',5,main]) completed. Took 0.753 secs. :processResources (Thread[Task worker for ':',5,main]) started.
Task :processResources UP-TO-DATE Skipping task ':processResources' as it is up-to-date. :processResources (Thread[Task worker for ':',5,main]) completed. Took 0.003 secs. :classes (Thread[Task worker for ':',5,main]) started.
Task :classes UP-TO-DATE Skipping task ':classes' as it has no actions. :classes (Thread[Task worker for ':',5,main]) completed. Took 0.0 secs. :war (Thread[Task worker for ':',5,main]) started.
Task :war SKIPPED Skipping task ':war' as task onlyIf is false. :war (Thread[Task worker for ':',5,main]) completed. Took 0.0 secs.
最佳答案
我猜您除了war插件之外,还已经将spring boot gradle插件应用到了您的项目中?那么这种行为是正常的,因为Spring Boot插件将禁用jar和war任务,并将其替换为bootWar和bootJar任务。
在同时使用spring boot和war插件的情况下:
./gradlew war
15:35:09: Executing task 'war'...
> Task :compileJava UP-TO-DATE
> Task :processResources UP-TO-DATE
> Task :classes UP-TO-DATE
> Task :war SKIPPED
BUILD SUCCESSFUL in 0s
2 actionable tasks: 2 up-to-date
15:35:10: Task execution finished 'war'.
$ ./gradlew bootWar
15:36:35: Executing task 'bootWar'...
> Task :compileJava UP-TO-DATE
> Task :processResources UP-TO-DATE
> Task :classes UP-TO-DATE
> Task :bootWar
BUILD SUCCESSFUL in 1s
3 actionable tasks: 1 executed, 2 up-to-date
15:36:37: Task execution finished 'bootWar'.
关于gradle - 如何用gradle构建WAR文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52314693/
我是一名优秀的程序员,十分优秀!