我正在尝试从build.gradle文件中运行Groovy类.我正在遵循使用指南中的指示,但是我收到了错误.
构建文件是:
apply plugin: 'java'
apply plugin: 'groovy'
main {
java {
srcDirs = ["$projectDir/src/java"]
}
groovy {
srcDirs = ["$projectDir/src/groovy"]
}
}
dependencies {
compile 'org.codehaus.groovy:groovy-all:2.2.0', files(....)
}
task fooTask << {
groovyClass groovyClass = new groovyClass()
groovyClass.foo()
}
Run Code Online (Sandbox Code Playgroud)
groovy类非常简单:
public class groovyClass {
public void foo() {
println 'foo'
}
}
Run Code Online (Sandbox Code Playgroud)
但是,当我尝试运行gradlew编译fooTask时,我收到以下错误:
无法解析类groovyClass
知道为什么吗?
谢谢
我正在尝试将一个ant构建文件转换为Gradle,我想知道是否存在一种方法来指定哪些包应该在javadoc中,就像'packagenames'在ant中工作一样?
谢谢乔纳森
我正在将一个ant构建文件迁移到gradle并遇到以下问题.
ant build启动第二个构建文件,指定-lib指向包含dost.jar和resolver.jar的文件夹(下面提供了代码)
<java classname="org.apache.tools.ant.launch.Launcher" fork="true" failonerror="true">
<jvmarg value="-Xmx256M" />
<classpath>
<pathelement location="${ant.home}/lib/ant-launcher.jar" />
</classpath>
<jvmarg value="-Dant.library.dir=${ant.home}/lib" />
<arg value="-Djava.awt.headless=true" />
<arg value="-buildfile" />
<arg file="build-manual.xml" />
<arg value="-lib" />
<arg file="${resource.dir}/lib" />
</java>
Run Code Online (Sandbox Code Playgroud)
启动的构建文件执行的任务使用xmlcatalog来运行XSLT任务
<xslt classpath="${saxon.jar}"
style="${src.dir}/resources/dita-to-changes.txt.xsl"
in="${basedir}/manual/dita/topic/something.dita"
out="${dist.dir}/something.txt">
<xmlcatalog>
<catalogpath>
<path location="${lib.dir}/dita/catalog-dita.xml" />
</catalogpath>
</xmlcatalog>
</xslt>
Run Code Online (Sandbox Code Playgroud)
我试图放弃从启动器启动任务,只是运行第二个任务,因此我创建了以下任务
ant.xslt(
classpath : "$projectDir/lib/misc/saxon9.jar:$projectDir/lib/misc/saxon9-dom.jar:
$projectDir/lib/misc/saxon9-ant.jar:$resource.dir/lib/resolver.jar",
basedir : "manual/dita", style : "$ditaLib/custom/dita2html.xsl", destdir : "$manualBuild") {
param(name: "versionname", expression : versionName)
xmlcatalog {
catalogpath {
path(location: "$ditaLib/catalog-dita.xml")
}
}
}
Run Code Online (Sandbox Code Playgroud)
哪个falis有以下错误
[ant:xslt] …Run Code Online (Sandbox Code Playgroud) 我创建了一个外部JAR,其中包含一个简单的Spring REST控制器,其中包含以下代码:
@RestController
@RequestMapping("/hello")
public class HelloController {
@RequestMapping(value = "/world")
public Hello hello() {
System.out.println("HELLO WORLD");
return new Hello(1L, "Hello World");
}
}
Run Code Online (Sandbox Code Playgroud)
然后,我将这个小项目编译到一个名为hello.jar的jar中,然后将其添加到Spring Boot应用程序的类路径中并启动该应用程序。
我还将该软件包添加到了ComponentScan中,如下所示:
@SpringBootApplication
@Configuration
// @Controller
// @org.springframework.context.annotation.Configuration
@ComponentScan(basePackages = {"main.java.foo.hello" })
@EnableEntityLinks
@EnableAutoConfiguration
public class Main {
public static void main(final String[] args) throws Exception {
ClassLoader classLoader = ClassLoader.getSystemClassLoader();
URL[] urls = ((URLClassLoader)classLoader).getURLs();
for (URL url : urls) {
if (url.getPath().contains("hello")) {
System.out.println(url.getPath());
}
}
SpringApplication.run(Main.class);
}
}
Run Code Online (Sandbox Code Playgroud)
由于打印出来,我可以看到jar已加载到应用程序中,并且通过将日志添加到Spring Boot Application中,我可以看到Controller已被扫描并被拾取(或至少看起来是被拾取)。 …
如何获得 GPathResult 的下一个兄弟?例如,我有以下代码:
def priorityIssue = xmlReport.'**'.find { Issue ->
Issue.Priority.text() == priority
}
Run Code Online (Sandbox Code Playgroud)
我如何获得 priorityIssue 的下一个兄弟姐妹?
谢谢!
我正在尝试创建 OpenAPI yml 文档文件(通过 swagger)。我的 API 调用之一返回资源列表。每个资源都有属性、一个自链接和一个到附加链接的链接,该链接将检索与资源相关的附加“资料”。
请看下面的例子:
[
{
"name": "object-01",
"links": [
{
"rel": "self",
"href": "http://localhost:8800/foo/object-01"
},
{
"rel": "Supported stuff",
"href": "http://localhost:8800/foo/object-01/stuff"
}
]
}, {
"name": "object-02",
"links": [
{
"rel": "self",
"href": "http://localhost:8800/foo/object-02"
},
{
"rel": "Supported stuff",
"href": "http://localhost:8800/foo/object-02/stuff"
}
]
}, {
"name": "object-03",
"links": [
{
"rel": "self",
"href": "http://localhost:8800/foo/object-03"
},
{
"rel": "Supported stuff",
"href": "http://localhost:8800/foo/object-03/stuff"
}
]
}
]
Run Code Online (Sandbox Code Playgroud)
我不确定记录这一点的正确方法是什么,这就是我现在所拥有的。
paths:
/foo/objects:
get:
operationId: getObject
responses:
'200':
description: Respresentation …Run Code Online (Sandbox Code Playgroud) 我正在尝试运行一个执行存储在host_vars中的变量的剧本.这是解决方案布局:
文件内容如下:
/存货/主机:
[f5-test]
localhost
Run Code Online (Sandbox Code Playgroud)
/ host_vars /主机
f5_user:user
f5_password:password
f5_server:server
Run Code Online (Sandbox Code Playgroud)
/playbook.yml
- name: Playbook
hosts: f5-test
gather_facts: no
gather_subset: no
tasks:
- name: Taks_01
tags: "bigip-node"
bigip_node:
server: "{{f5_server}}"
user: "{{f5_user}}"
password: "{{f5_password}}"
state: "present"
partition: "Common"
host: "10.20.30.40"
name: "F5_Node"
session_state: "enabled"
description: "description"
delegate_to: localhost
Run Code Online (Sandbox Code Playgroud)
但是,当我们执行以下命令时:
sudo ansible-playbook playbook.yml -i inventory/hosts -vvvv
我收到以下错误:
task path: /home/dev/ansible/playbook.yml:9
fatal: [localhost]: FAILED! => {
"failed": true,
"msg": "the field 'args' has an invalid value, which appears …Run Code Online (Sandbox Code Playgroud) 提出关于spring和tomcat的问题.我有以下代码
BookDAOImpl.java
@Repository
public class BookDAOImpl extends NamedParameterJdbcDaoSupport implements BookDAO {
private class BookMapper implements RowMapper<Book> {
@Override
public Book mapRow(ResultSet resultSet, int rowNum) throws SQLException {
Book book = new Book();
book.setId(resultSet.getInt("id"));
book.setTitle(resultSet.getString("title"));
book.setAuthor(resultSet.getString("author"));
book.setPublisher(resultSet.getString("publisher"));
book.setPublicationDate(resultSet.getDate("publication_date"));
book.setIsbn(resultSet.getString("isbn"));
book.setAvailable(resultSet.getBoolean("available"));
return book;
}
}
}
Run Code Online (Sandbox Code Playgroud)
LibraryDataSource.java
@Component("dataSource")
public class LibraryDataSource extends DriverManagerDataSource {
@Autowired
public LibraryDataSource(@Value("${url}")String url, @Value("${user}")String username, @Value("${password}")String password) {
super(url, username, password);
}
}
Run Code Online (Sandbox Code Playgroud)
应用程序的context.xml
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-4.0.xsd"
default-autowire="byName">
<context:annotation-config/> …Run Code Online (Sandbox Code Playgroud)