我正在尝试使用JDK8运行aspectj-maven插件.但它给出的错误如"java.lang.CharSequence类型无法解析.它是从所需的.class文件间接引用的"
有关如何解决的任何帮助,或者aspectj-maven-plugin是否支持JDK8.我正在使用1.6版本的aspectj - maven-plugin.
我有以下数据:
{"action":"CREATE","docs":1,"date":"2016 Jun 26 12:00:12","userid":"1234"}
{"action":"REPLACE","docs":2,"date":"2016 Jun 27 12:00:12","userid":"1234"}
{"action":"REPLACE","docs":1,"date":"2016 Jun 27 13:00:12","userid":"1234"}
{"action":"CREATE","docs":1,"date":"2016 Jun 28 12:00:12","userid":"3431"}
{"action":"REPLACE","docs":2,"date":"2016 Jun 28 13:00:12","userid":"3431"}
{"action":"CREATE","docs":1,"date":"2016 Jun 29 12:00:12","userid":"9999"}
Run Code Online (Sandbox Code Playgroud)
为了按日期(降序)获取每个唯一用户订单的记录,我使用了如下所示的Top Hits:
"aggs": {
"user_bucket": {
"terms": {
"field": "userid"
},
"aggs": {
"user_latest_count": {
"top_hits": {
"size": 1,
"sort": [
{
"data": {
"order": "desc"
}
}
],
"_source": {
"include": [
"docs"
]
}
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
以上查询的结果如下:
{"action":"REPLACE","docs":1,"date":"2016 Jun 27 13:00:12","userid":"1234"}
{"action":"REPLACE","docs":2,"date":"2016 Jun 28 13:00:12","userid":"3431"}
{"action":"CREATE","docs":1,"date":"2016 Jun 29 12:00:12","userid":"9999"}
Run Code Online (Sandbox Code Playgroud)
现在,我想进一步聚合这个,结果如下: …
我试图将缓存添加到CRUD应用程序,我开始执行以下操作:
@Cacheable("users")
List<User> list() {
return userRepository.findAll()
}
@CachePut(value = "users", key = "#user.id")
void create(User user) {
userRepository.create(user)
}
@CachePut(value = "users", key = "#user.id")
void update(User user) {
userRepository.update(user)
}
@CacheEvict(value = "users", key = "#user.id")
void delete(User user) {
userRepository.delete(user)
}
Run Code Online (Sandbox Code Playgroud)
我的问题是我希望create / update / delete操作可以为该操作更新已存储在缓存中的元素list()
(请注意,list()
不是从数据库中拉出而是从数据引擎中拉出),但是我无法做到这一点。
我想缓存list()
单独返回的所有元素,以便所有其他操作可以使用来更新缓存#user.id
。或者,可能需要执行所有操作来更新已存储在缓存中的列表。
我读到我可以在更新整个缓存时逐出整个缓存,但是我想避免这样的事情:
@CacheEvict(value = "users", allEntries=true)
void create(User user) {
userRepository.create(user)
}
Run Code Online (Sandbox Code Playgroud)
有什么方法可以在缓存的集合中创建/更新/删除值?还是将集合中的所有值作为单独的键缓存?
我们有大约10个不同的应用程序,它们是使用Groovy的Spring Boot项目.
我们所有的项目都在所有开发人员工作站中正确构建,并且它们正常运行直到昨天,但突然所有项目今天仅在我们的GitLab CI管道中停止工作且出现以下错误:
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:37 min
[INFO] Finished at: 2018-10-31T17:49:11Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.21.0:test (default-test) on project ctg-oms-component: There are test failures.
[ERROR]
[ERROR] Please refer to /builds/ctg-integrations/ctg-oms-component/target/surefire-reports for the individual test results.
[ERROR] Please refer to dump files (if any exist) [date]-jvmRun[N].dump, [date].dumpstream and [date]-jvmRun[N].dumpstream.
[ERROR] ExecutionException The forked VM terminated without properly saying …
Run Code Online (Sandbox Code Playgroud) 我需要通过在 中放置一个目录来复制我们的生产环境/reports/2019/
,正如您所知,这在 Catalina 中不再可能(至少在不禁用 SIP 的情况下)。
这样做实际上是在禁用安全性,但我想有一种正确的方法可以做到这一点。
有/reports
没有办法在不禁用 SIP 或不影响安全性的情况下创建一个链接到读写卷的符号链接?
我想在Jersey控制器上创建一个Aspect来衡量服务执行的时间.我正在反对我的切入点,因为它没有被检测到,我的方面永远不会被启动.
我尝试过使用许多切入点,例如:
execution(@Monitor * *.*(..))
execution(public * *(..))
change the order of @Aspect and @Component
Added a pointcut like this:
@Pointcut("execution(@Monitor * *.*(..))")
public void monitorRequestTargets(){}
@Around("monitorRequestTargets()")
Tried using AOP and CGLIB
<aop:aspectj-autoproxy proxy-target-class="true"/>
Also tried changing the order of configuration in context.xml
Run Code Online (Sandbox Code Playgroud)
Eclipse检测到我的方法正在建议我的方法,但它不会在运行时执行.你能否给我一些提示,说明为什么没有创建方面或切入点没有启动?
我的代码如下.
的context.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">
<!-- Enables the Spring MVC @Controller -->
<annotation-driven />
<!-- Enables AspectJ -->
<aop:aspectj-autoproxy />
<!-- .....more …
Run Code Online (Sandbox Code Playgroud) 我正在使用 Spock 作为测试框架,使用 Apache Camel 路由为 Spring Boot 应用程序创建一些单元测试,并且我需要模拟来自另一个应用程序的响应。我为此制作了一个模拟控制器,但我需要将测试运行的端口注入到属性中。有没有办法获取正在运行测试的端口?
\n\n我尝试过
\n\n@LocalServerPort\nprivate int port \n
Run Code Online (Sandbox Code Playgroud)\n\n与
\n\n@Autowired Environment environment;\nString port = environment.getProperty("local.server.port");\n
Run Code Online (Sandbox Code Playgroud)\n\n但两者都返回 -1,我不知道\xc2\xb4t 是否有其他方法来获取端口
\n\n我的测试配置了以下注释:
\n\n@RunWith(SpringRunner)\n@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)\n@ActiveProfiles(\'test\')\n
Run Code Online (Sandbox Code Playgroud)\n\n另外,有没有办法在文件中注入随机端口application-test.yml
?理想情况下,我需要在我的application-test.yml
文件中执行类似的操作:
app:\n service: localhost:${server.port}\n
Run Code Online (Sandbox Code Playgroud)\n\n其中端口是运行测试的随机端口。
\n现在我有这样的查询:
{
"query": {
"bool": {
"must": [
{
"match": {
"uuid": "xxxxxxx-xxxx-xxxx-xxxxx-xxxxxxxxxxxxx"
}
},
{
"range": {
"date": {
"from": "now-12h",
"to": "now"
}
}
}
]
}
},
"aggs": {
"query": {
"terms": [
{
"field": "query",
"size": 3
}
]
}
}
}
Run Code Online (Sandbox Code Playgroud)
聚合效果非常好,但我似乎无法找到一种方法来控制返回的命中数据,我可以使用dsl顶部的size参数,但返回的命中不会返回以桶为单位,因此桶结果不符合命中结果.有没有办法纠正这个问题,还是我必须发出2个单独的查询?
我正在学习具有环视(lookbehind 和lookahead)功能的正则表达式,但我不能在lookbehind 中使用.*
或.+
量词(但我可以使用lookahead)。
我试图修复的正则表达式如下:
(?<!yellow.*)blue(?=.*brown)
Run Code Online (Sandbox Code Playgroud)
这个想法是匹配那些没有yellow
但blue
只有brown
在蓝色之后存在的线。以下是一些示例:
yellow blue brown // shouldn't match
f blue brown // should match
sdff blue brown // should match
asdf f blue c // shouldn't match
yellow blue fblue b f brown // shouldn't match
Run Code Online (Sandbox Code Playgroud)
这是我的测试:
http://regex101.com/r/fY4kI9/5
我得到的错误是:
。* Lookbehinds 必须是零宽度,因此不允许使用量词
你知道我该如何解决这个问题吗?
我想从控制器建议方面抛出一个标准的自定义异常,但由于某种原因,我的自定义异常没有被 Spring Boot (1.3.3-RELEASE) 捕获。
这是我的代码:
我的测试
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(MyApplication.class)
@WebIntegrationTest("server.port:9000")
public class ControllerTest {
private final String URL = "http://localhost:9000";
@Test
public void testCustomExceptionResponse() {
// Invoke my controller generating some exception
Map error = restTemplate.getForObject(URL+"/exception/", Map.class);
assertTrue(error.get("exception").contains("MyCustomException"));
}
}
Run Code Online (Sandbox Code Playgroud)
控制器
@RequestMapping(value = "/", method = RequestMethod.GET)
public List<Object> findAll() throws Exception {
// generate whatever exception here
if (1<2) throw new IllegalIdentifierException("test whatever exception");
return ccRepository.findByActive(true);
}
Run Code Online (Sandbox Code Playgroud)
使用 @ControllerAdvice 注释的 GlobalExceptionHandler
@ControllerAdvice
public class GlobalExceptionHandler {
private static final …
Run Code Online (Sandbox Code Playgroud) java ×6
spring-boot ×4
spring ×3
aspectj ×2
aggregation ×1
aop ×1
caching ×1
docker ×1
gitlab ×1
gitlab-ci ×1
jersey ×1
macos ×1
maven ×1
maven-plugin ×1
regex ×1
spring-aop ×1
spring-cache ×1
spring-mvc ×1