小编Dan*_*ton的帖子

Spring data jpa:未找到类 ConnectionManager 所需的标识符属性

当尝试通过控制器方法中的 CrudRepository 保存 ConnectionManager 类时,出现错误“未找到类 ConnectionManager 所需的标识符属性”。

我有一个 ConnectionManager,它与 DocumentDetail 具有一对一的关系,而 DocumentDetail 与 DocumentValidation 具有一对多的关系。

Hibernate 从实体生成架构,我可以在数据库中看到一个 id 字段。在控制台中,这是创建 ConnectionManager 表的日志。

Hibernate:创建表connection_manager(默认生成的id bigint为identity,control_id bigint,序列整数不为空,类型varchar(255),document_detail_id bigint,email_detail_id bigint,sql_detail_id bigint,主键(id))

  @Entity
 public class ConnectionManager {

 @Id
 @GeneratedValue(strategy = GenerationType.IDENTITY)
 private Long id;

 private Long controlId;

private int sequence;



public enum ValidationType {Email, Document, Sql};
@Enumerated(EnumType.STRING)
private ValidationType type;


@OneToOne

@MapsId
private EmailDetail emailDetail;

@OneToOne
@MapsId
private DocumentDetail documentDetail;

@OneToOne

@MapsId
private SqlDetail sqlDetail;

public ConnectionManager(){};
//getters setters
DocumentDetail
Run Code Online (Sandbox Code Playgroud)

文件详情

@Entity
public class DocumentDetail …
Run Code Online (Sandbox Code Playgroud)

hibernate spring-data-jpa spring-boot

7
推荐指数
3
解决办法
2万
查看次数

Spring Cloud Sleuth- Get current traceId?

我正在使用 Sleuth,我想知道是否可以获取当前的 traceId?我不需要添加任何回复或任何东西。我只想要在某些情况下提醒开发团队的电子邮件的 traceId。

spring-boot spring-cloud-sleuth

7
推荐指数
2
解决办法
4836
查看次数

使用 AWS SES SMTP-错误 554 消息被拒绝:电子邮件地址未验证。以下身份未通过区域签到

在我尝试向其发送电子邮件的电子邮件地址上收到此错误!

不知道为什么我需要验证我发送的不属于我的电子邮件?

调试 SMTP:发送时出现 MessagingException,抛出:com.sun.mail.smtp.SMTPSendFailedException:554 消息被拒绝:电子邮件地址未验证。以下身份未通过 EU-WEST-1 区域的检查:danielhaughton@outlook.com

@Configuration
@PropertySource("app.properties")
@EnableTransactionManagement
public class AppConfig {
@Autowired
private Environment env;
@Bean
public JavaMailSender getJavaMailSender() {
    JavaMailSenderImpl mailSender = new JavaMailSenderImpl();
    mailSender.setHost("email-smtp.eu-west-1.amazonaws.com");
    mailSender.setPort(25);
    mailSender.setUsername("removedcreds");
    mailSender.setPassword("removed creds");
    Properties props = mailSender.getJavaMailProperties();
    props.put("mail.transport.protocol", "smtp");
    props.put("mail.smtp.auth", "true");
    props.put("mail.smtp.starttls.enable", "true");
    props.put("mail.smtp.starttls.required", "true");

    props.put("mail.debug", "true");
    return mailSender;
}
Run Code Online (Sandbox Code Playgroud)

EmailService @Component 公共类 EmailServiceImpl {

@Autowired
public JavaMailSender emailSender;

public void sendSimpleMessage(String toAddress, String subject, String text) 
{
    SimpleMailMessage message = new SimpleMailMessage();
    message.setTo(toAddress);
    message.setFrom("noreply@mydomain.com");
    message.setSubject(subject);
    message.setText(text);
    emailSender.send(message);
} …
Run Code Online (Sandbox Code Playgroud)

amazon-web-services amazon-ses spring-boot

5
推荐指数
2
解决办法
9048
查看次数

使用 Gradle - 在 META-INF/spring.factories 中找不到自动配置类

尝试部署一个我在 Spring Boot 上使用 IntelliJ 中的 gradle 中的 jar 函数构建的 jar。它使用“bootrun”从我的 IDE 本地运行良好,但没有将 jar 放在 Linux 服务器上。服务器上的完整错误是

应用程序启动失败 org.springframework.beans.factory.BeanDefinitionStoreException:无法处理配置类 [haughton.icecreamapi.config.AppConfig] 的导入候选者;嵌套异常是 java.lang.IllegalArgumentException: 在 META-INF/spring.factories 中找不到自动配置类。如果您使用自定义包装,请确保该文件正确。

我的构建.gradle

group 'IceCreamApiCA1'
version '1.0-SNAPSHOT'
buildscript {

ext {
    springBootVersion = '1.5.9.RELEASE'
}
repositories{
    mavenCentral()
}
dependencies {
    classpath("org.springframework.boot:spring-boot-gradle-
 plugin:${springBootVersion}")    }
 }

 // Apply the Spring Boot plugin
 //apply plugin: 'spring-boot'
 apply plugin: 'org.springframework.boot'
 // Apply the Java plugin (expects src/main/java to be source folder)
 apply plugin: 'java'

  // Specify the location where our dependencies …
Run Code Online (Sandbox Code Playgroud)

intellij-idea gradle spring-boot

4
推荐指数
1
解决办法
9079
查看次数

Hibernate:collection with cascade="all-delete-orphan" 不再被拥有的实体实例引用

所以我有一个包含 DateActiveScheduleItem 列表的日程表对象。我从数据库中获取日程表,从列表中删除一个 DateActiveScheuleItem,并使用 Hibernate CrudRepository 中的 .save() 保存它。

nested exception is org.springframework.orm.jpa.JpaSystemException: A collection with cascade="all-delete-orphan" was no longer referenced by the owning entity instance: haughton.daniel.ShoutLoud.model.schedule.Schedule.dateActiveScheduleItems; nested exception is org.hibernate.HibernateException: A collection with cascade="all-delete-orphan" was no longer referenced by the owning entity instance: haughton.daniel.ShoutLoud.model.schedule.Schedule.dateActiveScheduleItems] with root causeorg.hibernate.HibernateException: A collection with cascade="all-delete-orphan" was no longer referenced by the owning entity instance: haughton.daniel.ShoutLoud.model.schedule.Schedule.dateActiveScheduleItems
Run Code Online (Sandbox Code Playgroud)

时间表.java

@Entity
public class Schedule {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@ManyToOne
@JoinColumn(name = "user_id")
private …
Run Code Online (Sandbox Code Playgroud)

hibernate jpa spring-data-jpa spring-boot

4
推荐指数
2
解决办法
2万
查看次数

CrudRepository:saveAll - 找不到类型的属性 saveAll

尝试为实体的 Iterable 创建 saveAll 方法。

完整错误是无法创建查询方法公共抽象java.lang.Iterable com.myCompany.mappingPoc.ConnectionManagerRepo.saveAll(java.lang.Iterable)!未找到 ConnectionManager 类型的属性 saveAll!

@Repository
public interface ConnectionManagerRepo extends CrudRepository<ConnectionManager, Long> {

Iterable<ConnectionManager> findAllByControlId(Long controlId);

Page<ConnectionManager> findAllByControlId(Pageable p, Long controlId);

Iterable<ConnectionManager> saveAll(Iterable<ConnectionManager> connectionManagers);
}
Run Code Online (Sandbox Code Playgroud)

hibernate spring-data-jpa

3
推荐指数
1
解决办法
5344
查看次数

3
推荐指数
1
解决办法
4512
查看次数

Spring Boot:在同一个项目中验证无状态REST API和状态"登录"Web控制器?

所以我有一个包含REST API的应用程序,它由IOT设备上的自定义Java应用程序使用,没有用户交互.我还有一个Web应用程序需要有状态会话来维护用户登录.

是否可以使用Spring Security以不同方式验证对我的API和Web控制器的请求?我应该使用什么形式的身份验证来进行REST API?

spring spring-security spring-boot

2
推荐指数
1
解决办法
1865
查看次数