所以今天我遇到了一个问题,@Formula 没有按我的预期工作。让我们说:
数据库
year | X | Y
-----+-----+-----
2010 | A | 10
2011 | A | 20
2011 | B | 99
2009 | C | 30
2010 | C | 40
Run Code Online (Sandbox Code Playgroud)
我想获得“Y”最高的年份并按“X”分组,所以我编写了这样的查询
SELECT year
FROM (SELECT
year,
MAX(y) OVER (PARTITION BY x ) max_y
FROM TableB) q
WHERE year = '2011' and x = 'A';
Run Code Online (Sandbox Code Playgroud)
所以结果是
year |
-----+
2011 |
Run Code Online (Sandbox Code Playgroud)
然后我想在实体中使用它,所以我用 @Formula 创建实体
@Formula("(SELECT year FROM (SELECT b.year, MAX(b.y) OVER(PARTITION BY b.x) max_y FROM TableB b) …Run Code Online (Sandbox Code Playgroud) 我只是尝试在EC2实例上与NTP服务器同步时间:
服务器0.amazon.pool.ntp.org的iBurst
服务器1.amazon.pool.ntp.org的iBurst
服务器2.amazon.pool.ntp.org的iBurst
服务器3.amazon.pool.ntp.org的iBurst
不幸的是,我无法与NTP-Server同步.我的问题是:
在此先感谢
Toan Dao
我目前从Spring Boot 1.4 - > 2.0迁移,然后我遇到了一个问题:
@GetMapping("/sample")
public Page<SampleDTO> doSomethings(@RequestParam("name") String name, Pageable pageable)
Run Code Online (Sandbox Code Playgroud)
我的存储库:
public interface SampleRepository extends JpaRepository<Sample, String>, QuerydslPredicateExecutor<Sample> {
Page<Sample> findByNameContainingIgnoreCase(String name, Pageable pageable);
Run Code Online (Sandbox Code Playgroud)
所以,当我调用API时:
http://localhost:8088/api/v1/sample?name=abc&page=0&size=10&sort=name,asc
Run Code Online (Sandbox Code Playgroud)
我注意到JPA已翻译成此查询:
Spring Boot 1.5
select *
from ( select row_.*, rownum rownum_
from ( select ... from sample sample0_ where upper(sample0_.name) like upper(?)
order by sample0_.name asc )
row_ where rownum <= ?) where rownum_ > ?
Run Code Online (Sandbox Code Playgroud)
Spring Boot 2.0
select ...
from sample sample0_
where upper(sample0_.name) like upper(?)
order …Run Code Online (Sandbox Code Playgroud) 所以我只是在玩Spring Boot 2.0.4,我今天注意到了这一点。不知道我错过了什么。请帮我检查一下。
春季申请
@SpringBootApplication
@EnableScheduling
public class Application extends SpringBootServletInitializer {
Run Code Online (Sandbox Code Playgroud)
application.properties(位于src / main / resources中)
server.port=8088
Run Code Online (Sandbox Code Playgroud)
使用Intellij启动项目
2018-08-17 12:11:05 INFO o.s.b.w.e.tomcat.TomcatWebServer - Tomcat started on port(s): 8088 (http) with context path ''
Run Code Online (Sandbox Code Playgroud)
使用java命令行启动项目:
java -jar sample.jar --spring.config.location=D:\config\ --spring.profiles.active=dev
Run Code Online (Sandbox Code Playgroud)
应用程序未使用配置的端口
2018-08-17 11:25:25 INFO o.s.b.w.e.tomcat.TomcatWebServer - Tomcat started on port(s): 8080 (http) with context path ''
Run Code Online (Sandbox Code Playgroud)
看起来Spring Boot 2.0忽略了默认属性文件(请注意:此配置仅在applications.properties中,其他位置无,因此不会与其他配置文件重叠)
spring-boot ×3
java ×2
oracle ×2
spring ×2
amazon-ec2 ×1
hibernate ×1
jpa ×1
jpa-2.0 ×1
ntp ×1
rest ×1