我有一个spring boot应用程序,我想为它添加liquibase配置更改日志.
我创建了一个用于配置liquibase的LiquibaseConfig类:
@Configuration
public class LiquibaseConfiguration {
@Value("${com.foo.bar.liquibase.changelog}")
private String changelog;
@Autowired
MysqlDataSource dataSource;
@Bean
public SpringLiquibase liquibase() {
SpringLiquibase liquibase = new SpringLiquibase();
liquibase.setDataSource(dataSource);
liquibase.setChangeLog(changelog);
return liquibase;
}
}
Run Code Online (Sandbox Code Playgroud)
我已在属性文件中配置了数据源信息:
spring.datasource.url=jdbc:mysql://localhost:3306/dms
spring.datasource.username=root
spring.datasource.password=test
spring.datasource.testWhileIdle = true
spring.jpa.show-sql = true
#liquibase
com.foo.bar.liquibase.changelog=classpath:/db/changelog/db.changelog.xml
Run Code Online (Sandbox Code Playgroud)
当我运行我的应用程序时,我收到此错误:
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'liquibaseConfiguration': Unsatisfied dependency expressed through field 'dataSource': No qualifying bean of type [com.mysql.jdbc.jdbc2.optional.MysqlDataSource] found for dependency [com.mysql.jdbc.jdbc2.optional.MysqlDataSource]: expected at least 1 bean which qualifies as autowire candidate for this dependency. …Run Code Online (Sandbox Code Playgroud) 你好,我有一个对象列表,我的对象有三个字段
class MyObject{
String x;
String y;
int z;
//getters n setters
}
Run Code Online (Sandbox Code Playgroud)
我需要将此列表转换为 Map<String,Map<String,Integer>>
就像这样:
{x1:{y1:z1,y2:z2,y3:z3},x2{y4:z4,y5:z5}}格式我想在Java 8中这样做,我认为我相对较新.
我尝试过以下方法:
Map<String,Map<String,Integer>> map=list.stream().
collect(Collectors.
groupingBy(MyObject::getX,list.stream().
collect(Collectors.groupingBy(MyObject::getY,
Collectors.summingInt(MyObject::getZ)))));
Run Code Online (Sandbox Code Playgroud)
这甚至没有编译.非常感谢帮助
我的项目有一个问题,即项目 pom 文件有一个错误,指出打包不应解析为 jar 而应解析为 pom。我需要我的项目生成一个目标“jar”,并且我没有任何子模块,但是此错误是由另一个错误生成的:Child module of pom.xml does not exist现在这是我的 pom 文件:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.itworx.bigdata</groupId>
<artifactId>MediaSensor</artifactId>
<version>0.0.1</version>
<name>MediaSensor</name>
<description>Complete and Integrated Spark Flow of Big Data</description>
<repositories>
<repository>
<id>cloudera</id>
<url>https://repository.cloudera.com/artifactory/cloudera-repos/</url>
</repository>
</repositories>
<!-- please stick to the CDH version and this repositry do not use apache repos -->
<!-- All CDH jars in this link http://www.cloudera.com/content/cloudera/en/documentation/core/latest/topics/cdh_vd_cdh5_maven_repo.html#concept_jhf_dcz_bs_unique_2-->
<dependencies>
<!-- following jar is implicitly needed by one of spark ref -->
<dependency>
<groupId>jdk.tools</groupId>
<artifactId>jdk.tools</artifactId> …Run Code Online (Sandbox Code Playgroud) 我得到以下异常:
org.hibernate.loader.MultipleBagFetchException:无法同时获取多个行李
我使用的bean是:
@Entity
@Table(name="user")
public class User implements Serializable {
/**
*
*/
private static final long serialVersionUID = -5689970869179555442L;
@Id
@Column(name="username")
/*@NotNull*/
private String username;
@Column(name="password")
private String password;
@Column(name="email")
/*@Email*/
private String email;
@LazyCollection(LazyCollectionOption.FALSE)
@ManyToMany
@JoinTable(name="user_follower",joinColumns={@JoinColumn(name="username")},
inverseJoinColumns={@JoinColumn(name="follower")})
private List<User> followers = new ArrayList<User>(0);
/*@LazyCollection(LazyCollectionOption.FALSE)*/
@OneToMany(fetch=FetchType.EAGER)
@JoinTable(name="user_message",joinColumns={@JoinColumn(name="username")},
inverseJoinColumns={@JoinColumn(name="message_date")})
@OrderBy(value="messageDate")
private List<Message> messages = new ArrayList<Message>(0);
public User() {
}
Run Code Online (Sandbox Code Playgroud)
在dao我有以下代码:
public void followUser(String userToFollow, String username) {
System.out.println("repository invoked");
session=sessionFactory.getCurrentSession();
User user=retrieveUser(username);
@SuppressWarnings("unchecked")
List<User> followers=session.createCriteria(User.class).setFetchMode("followers", FetchMode.JOIN)
.add(Restrictions.eq("username", username)).list(); …Run Code Online (Sandbox Code Playgroud) 我面临分页问题。我正在使用标准。显示长度为10。单击分页时,它会显示不同的结果,例如列表为9和8之类。如何避免这种分页问题。我每次都需要清单 10。如何控制这种不一致。