我想从src中排除src\main和src\test文件
FileCollection files =
project.fileTree(/src/).minus(project.fileTree(/src\main/)).minus(project.fileTree(/src\test/))
Run Code Online (Sandbox Code Playgroud)
如何在没有双减去用法的情况下排除此目录?
class GreetingPluginExtension {
def String message = 'Hello from GreetingPlugin'
}
Run Code Online (Sandbox Code Playgroud)
为什么使用def
和String
同时,我们有String类型,为什么我们使用和def关键字?
所以在我写的命令行的Windows中
set GRADLE_OPTS = -Xdebug -Xrunjdwp:transport = dt_socket,address = 9999,server = y,suspend = y
然后我得到:
C:\Project>gradle main
Listening for transport dt_socket at address: 9999
Run Code Online (Sandbox Code Playgroud)
然后我在gradle.build文件中放了一个断点
最后来自Eclipse IDE
我明白了
为什么会这样?所以我无法调试gradle文件,我只能调试java,groovy ..文件?
我有一个具有这种结构的Gradle项目:
ls -alh
drwxr-xr-x 9 Xelian 4.0K Aug 5 22:39 .
drwxrwxr-x 3 Xelian 4.0K Aug 5 16:19 ..
-rw-rw-r-- 1 Xelian 465 Aug 5 16:19 build.gradle
drwxrwxr-x 8 Xelian 4.0K Aug 5 16:38 buildSrc
drwxrwxr-x 3 Xelian 4.0K Aug 5 16:19 gradle
drwxrwxr-x 3 Xelian 4.0K Aug 5 16:45 .gradle
-rwxrwxrwx 1 Xelian 5.0K Aug 5 17:29 gradlew
-rw-rw-r-- 1 Xelian 2.3K Aug 5 16:19 gradlew.bat
-rw-rw-r-- 1 Xelian 17K Aug 5 16:19 README.md
-rw-rw-r-- 1 Xelian 30 Aug …
Run Code Online (Sandbox Code Playgroud) 嗨,我尝试写入不存在的文件
public static void main(String[] args) throws IOException {
Path newFile = Paths.get("output.txt");
Files.write(newFile, "Sample text".getBytes());
}
Run Code Online (Sandbox Code Playgroud)
一切都好,但如果我把选项
Files.write(newFile, "Sample text".getBytes(),StandardOpenOption.DELETE_ON_CLOSE);
Run Code Online (Sandbox Code Playgroud)
出现错误
Exception in thread "main" java.nio.file.NoSuchFileException: problem.txt
at sun.nio.fs.WindowsException.translateToIOException(Unknown Source)
Run Code Online (Sandbox Code Playgroud)
所以为了工作,我必须添加选项
StandardOpenOption.CREATE_NEW
Run Code Online (Sandbox Code Playgroud)
为什么在第二次尝试StandardOpenOption.DELETE_ON_CLOSE
中不起作用,但第一次没有任何选项可以工作并创建文件?
我正在使用 java 版本(构建 1.7.0_45-b18)
嗨我有QueryDSL 3.6.0的Hibernate项目,当我在我的服务类中只有findAll()方法时,everyThing就可以了.但是当我添加findByID时会出现错误.
public class ArticleServiceImpl extends ArticleService {
QArticle article = QArticle.article;
@Override
public List<Article> findAll() {
return query.from(article).fetchAll().list(article);
}
public Article findById(@Nonnull final long id) {
return query.from(article).where(article.id.eq(id)).uniqueResult(article);
}
}
Run Code Online (Sandbox Code Playgroud)
错误是:
Exception in thread "main" java.lang.IllegalStateException: article is already used
at com.mysema.query.DefaultQueryMetadata.addJoin(DefaultQueryMetadata.java:160)
at com.mysema.query.support.QueryMixin.from(QueryMixin.java:189)
at com.mysema.query.jpa.JPAQueryBase.from(JPAQueryBase.java:88)
at com.mysema.query.jpa.JPAQueryBase.from(JPAQueryBase.java:32)
at com.example.hibernate.services.ArticleServiceImpl.findById(ArticleServiceImpl.java:30)
at com.example.hibernate.core.Main.main(Main.java:42)
Run Code Online (Sandbox Code Playgroud)
怎么了?我看到查询不是安全的.但是如何在两种不同的方法中使用Q-class呢?
编辑:
protected JPQLQuery query = new JPAQuery(entityManager);
Run Code Online (Sandbox Code Playgroud)
它是来自ArticleService的受保护变量.
我想根据参数代码是否为空来调用方法1或方法2
void add(def code, def index) {
method(index).((code != null) ? "method1"(code) : "method2"())
}
Run Code Online (Sandbox Code Playgroud)
但什么也没发生?我的错在哪里?如果我写
method(index)."method1"(code)
Run Code Online (Sandbox Code Playgroud)
有效但不能使三元运算符起作用。
我想在Groovy Map中转换我的xml元素配置,其中将所有conf元素放在Map<String, Map<String,String>>
其中String是conf-s元素的名称的形式
中,并且在值Map中有当前conf元素ex的另一个属性.
map[0] = {one,[visivility:public,description:Configuration one.]
<?xml version="1.0" encoding="UTF-8"?>
<bla-module version="2.0" >
<configurations>
<conf name="one" visibility="public" description="Configuration one."/>
<conf name="two" visibility="private" description="Configuration two."/>
</configurations>
</bla-module>
Run Code Online (Sandbox Code Playgroud)
尝试使用groovy语法和XMLSluper的最快方法是什么.PS conf-s元素中的属性数量未知
我有jar文件,里面有清单
Manifest-Version: 1.0
Build-Jdk: 1.7.0_67
Created-By: Apache Maven 3.2.3
Main-Class: com.company.main.Main
Archiver-Version: Plexus Archiver
Run Code Online (Sandbox Code Playgroud)
并且jar具有与外部库的编译依赖性
compile 'org.apache.commons:commons-lang3:3.3.2'
Run Code Online (Sandbox Code Playgroud)
所以我想执行它comandLine我写道:
java -cp C:\commons-lang3-3.3.2.jar -jar myJar-1.0.0.jar
Run Code Online (Sandbox Code Playgroud)
但
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/lang3/StringUtils
at ...
Run Code Online (Sandbox Code Playgroud)
如何在类路径上添加此文件?
PS.如果我使用"坏方法"并在... jre7\lib\ext文件夹中复制粘贴commons-lang3-3.3.2.jar.一切正常.
您好,在我的项目 Veracode 中报告了 XSS 问题 CWE ID 80。在我的请求处理程序方法中:
@RequestMapping(value = "/Update.mvc")
public @ResponseBody String execute(@ModelAttribute UpdateForm updateForm, BindingResult result,
HttpServletRequest request, HttpServletResponse response) throws ActionException {
return executeAjax(updateForm, request, response, result);
}
Run Code Online (Sandbox Code Playgroud)
那么executeAjax来自一个抽象类并且有不同的实现?在这些实现中,来自表单的用户输入被获取并被操纵以构造返回的字符串。
所以我的问题是:Veracode假设是在实现中可以有XSS吗?还是一般的东西?- 如何防止这种情况发生?我总是使用转换输入数据,并且当用户输入它时它不会返回?- 那么如何预防呢?- 我是否必须转义 HttpServiceRequest 中的所有标头/请求参数?
编辑: 我是否必须使用过滤器,例如: SecurityWrapperRequest