AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / user-10198012

dusk's questions

Martin Hope
dusk
Asked: 2025-04-27 04:35:39 +0800 CST

使用 Flutter 应用调用我的 Springboot API 时超时

  • 7

将我的 Flutter 版本升级到 3.29.3 后:

Flutter 3.29.3 • channel stable • https://github.com/flutter/flutter.git
Framework • revision ea121f8859 (2 weeks ago) • 2025-04-11 19:10:07 +0000
Engine • revision cf56914b32
Tools • Dart 3.7.2 • DevTools 2.42.3

我无法连接我的 SpringBoot 应用。我使用 openssl 生成的证书:

openssl.exe req -newkey rsa:2048 -keyout PRIVATEKEY.key -out MYCSR.csr

openssl.exe req -new -x509 -nodes -sha256 -days 365 -key PRIVATEKEY.key -out host.cert

openssl.exe pkcs12 -export -in host.cert -inkey PRIVATEKEY.key -out keystore.p12 -name myApp

使用 Postman,我的请求:https://localhost/auth/authenticate根据POST请求运行良好并提供我的 access_token。

现在,当我在实体手机上启动 Flutter 应用程序时,出现以下错误:

I/flutter ( 3796): ClientException with SocketException: Connection timed out (OS Error: Connection timed out, errno = 110), address = 192.168.1.40, port = 37950, uri=https://192.168.1.40/auth/authenticate
I/.example.xplore( 3796): Thread[2,tid=3802,WaitingInMainSignalCatcherLoop,Thread*=0xb40000732bd83c00,peer=0x15440320,"Signal Catcher"]: reacting to signal 3
I/.example.xplore( 3796): 
I/.example.xplore( 3796): Wrote stack traces to tombstoned
D/Looper  ( 3796): dumpMergedQueue
D/OplusLooperMsgDispatcher( 3796): dumpMsgWhenAnr

我的计算机上的本地 IP 地址(ipconfig)是192.168.1.40。

在我的 main.dart 中,我覆盖了createHttpClient(我认为这仅适用于 DEV,不适用于 PROD):

class MyHttpOverrides extends HttpOverrides {
  @override
  HttpClient createHttpClient(SecurityContext? context) {
    return super.createHttpClient(context)
      ..badCertificateCallback =
          (X509Certificate cert, String host, int port) => true;
  }
}

我POST在 Flutter 应用程序中的请求如下所示:

var response = await http.post(Uri.parse(login),
          headers: {"Content-Type": "application/json"},
          body: jsonEncode(reqBody))

如果您需要更多信息,请问我:)

感谢您的帮助!

flutter
  • 1 个回答
  • 24 Views
Martin Hope
dusk
Asked: 2024-11-13 18:57:33 +0800 CST

Flutter Column 小部件内的意外边距

  • 5

我正在一列内写代码,但大小出乎意料。我认为这是一个边距,但我不知道它在哪里。有人有这个东西吗?

Column(
      children: [
        Text("test"),
        // Here some margin, why ?
        Container(
          height: 200,
          child: ListView.builder(
            shrinkWrap: true,
            itemCount: answers.length,
            itemBuilder: (BuildContext context, int index) {
              return Text(answers[index]);
            }
          ),
        )
      ],
    );

在此处输入图片描述

我尝试用 SizedBox 代替我的 Container,但没有成功。也许这是正常的?
我尝试删除 SizedBox 或 Container,只获取我的 ListView,但这里总是空白。

这是 Flutter Inspector:
带有绿色边框的高度 20 是列表之前的文本“测试” 在此处输入图片描述

谢谢 !

flutter
  • 1 个回答
  • 40 Views
Martin Hope
dusk
Asked: 2024-10-27 03:45:03 +0800 CST

使用 JPA Spring Boot 评估表达式 intellij 时出现 Stackoverflow

  • 6

我今天问了一个问题,我创建了一个用户模型。

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Entity
@Table(name = "_user")
@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class,property = "id")
public class User implements UserDetails {

  @Id
  @GeneratedValue
  private Integer id;
  private String firstname;
  private String lastname;
  @NotNull
  @Column(unique=true)
  private String email;
  @NotNull
  @Column(unique=true)
  private String usrname;

  @NotNull
  @ColumnDefault("'img/avatar1.jpg'")
  private String avatar;

  @JsonIgnore
  private String password;

  @Enumerated(EnumType.STRING)
  private Role role;

  @JsonIgnore
  @OneToMany(mappedBy = "user")
  private List<Token> tokens;

在我的服务中,我想在评估方法时获得结果:

User updateUser = userRepository.getById(userId)
                .orElseThrow(() -> new ResourceNotFoundException("L'utilisateur n'existe pas avec l'id: " + userId));

这是我的 getById(用户 ID)

@Query(value = "SELECT * FROM _user u where u.id = :id", nativeQuery = true)
  Optional<User> getById(int id);

当我评估方法以获得结果时,我得到了这个:

在此处输入图片描述

但没有问题,因为我的代码继续执行..奇怪的是,在控制台中,我没有 StackOverflow 问题..

由于我遇到了错误,我想进入调试模式并评估结果ERROR [https-jsse-nio-443-exec-3] c.d.x.ExceptionHandler: Could not commit JPA transaction。


编辑

添加 fullstacktrace 并且我的 userId 是 int(1) 而不是字符串。

在此处输入图片描述

在此处输入图片描述

我希望有人遇到过这个错误并解决了它!

多谢

此致

java
  • 1 个回答
  • 28 Views
Martin Hope
dusk
Asked: 2023-09-06 22:13:58 +0800 CST

使用 JPA 注释对多列进行唯一约束

  • 5

当我使用 JPA 注释对多个列添加唯一约束时遇到问题。
我使用 PostgresSQL

我想在 3 列上添加唯一约束:“user_id”、“science_id”和“difficulty”

换句话说:我可以拥有

0, 1, "EASY"
0, 1, "HARD" <= 因为难度不同
0, 2, "EASY"
1, 2, "EASY"

但不是
0, 1, "EASY"
0, 1, "EASY" <= 不唯一
0, 2, "EASY"
1, 2, "EASY"

这是我的实体:

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Entity
@Table(name = "user_basket",
        uniqueConstraints = { @UniqueConstraint(
                columnNames = { "user_id", "science_id", "difficulty" }) })
public class UserBasket {

    @Id
    @GeneratedValue
    private Integer id;

    @JsonIgnore
    @OneToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "user_id")
    private User user;

    @JsonIgnore
    @OneToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "science_id")
    private Science science;

    @Enumerated(EnumType.STRING)
    private Difficulty difficulty;

    @Column(nullable = false, updatable = false)
    @CreationTimestamp
    private Timestamp addToBasket;

}

所以,我用邮递员添加:

{
    "scienceId": 1,
    "difficulty": "EASY"
}

并添加另一个但有另一个困难:

{
    "scienceId": 1,
    "difficulty": "HARD"
}

插入第二个时出现错误:

2023-09-06T16:04:00,284 ERROR [http-nio-8080-exec-4] o.h.e.j.s.SqlExceptionHelper: ERREUR: la valeur d'une clé dupliquée rompt la contrainte unique « uk_5cesgns8lwu884yww505jep8t »
  Détail : La clé « (science_id)=(1) » existe déjà.
2023-09-06T16:04:00,295 ERROR [http-nio-8080-exec-4] c.d.x.ExceptionHandler: could not execute statement [ERREUR: la valeur d'une clé dupliquée rompt la contrainte unique « uk_5cesgns8lwu884yww505jep8t »
  Détail : La clé « (science_id)=(1) » existe déjà.] [insert into user_basket (add_to_basket,difficulty,science_id,user_id,id) values (?,?,?,?,?)]
2023-09-06T16:04:00,295 ERROR [http-nio-8080-exec-4] c.d.x.ExceptionHandler: org.springframework.dao.DataIntegrityViolationException: could not execute statement [ERREUR: la valeur d'une clé dupliquée rompt la contrainte unique « uk_5cesgns8lwu884yww505jep8t »
  Détail : La clé « (science_id)=(1) » existe déjà.] [insert into user_basket (add_to_basket,difficulty,science_id,user_id,id) values (?,?,?,?,?)]; SQL [insert into user_basket (add_to_basket,difficulty,science_id,user_id,id) values (?,?,?,?,?)]; constraint [null]

非常感谢,最诚挚的问候

java
  • 1 个回答
  • 31 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    重新格式化数字,在固定位置插入分隔符

    • 6 个回答
  • Marko Smith

    为什么 C++20 概念会导致循环约束错误,而老式的 SFINAE 不会?

    • 2 个回答
  • Marko Smith

    VScode 自动卸载扩展的问题(Material 主题)

    • 2 个回答
  • Marko Smith

    Vue 3:创建时出错“预期标识符但发现‘导入’”[重复]

    • 1 个回答
  • Marko Smith

    具有指定基础类型但没有枚举器的“枚举类”的用途是什么?

    • 1 个回答
  • Marko Smith

    如何修复未手动导入的模块的 MODULE_NOT_FOUND 错误?

    • 6 个回答
  • Marko Smith

    `(表达式,左值) = 右值` 在 C 或 C++ 中是有效的赋值吗?为什么有些编译器会接受/拒绝它?

    • 3 个回答
  • Marko Smith

    在 C++ 中,一个不执行任何操作的空程序需要 204KB 的堆,但在 C 中则不需要

    • 1 个回答
  • Marko Smith

    PowerBI 目前与 BigQuery 不兼容:Simba 驱动程序与 Windows 更新有关

    • 2 个回答
  • Marko Smith

    AdMob:MobileAds.initialize() - 对于某些设备,“java.lang.Integer 无法转换为 java.lang.String”

    • 1 个回答
  • Martin Hope
    Fantastic Mr Fox msvc std::vector 实现中仅不接受可复制类型 2025-04-23 06:40:49 +0800 CST
  • Martin Hope
    Howard Hinnant 使用 chrono 查找下一个工作日 2025-04-21 08:30:25 +0800 CST
  • Martin Hope
    Fedor 构造函数的成员初始化程序可以包含另一个成员的初始化吗? 2025-04-15 01:01:44 +0800 CST
  • Martin Hope
    Petr Filipský 为什么 C++20 概念会导致循环约束错误,而老式的 SFINAE 不会? 2025-03-23 21:39:40 +0800 CST
  • Martin Hope
    Catskul C++20 是否进行了更改,允许从已知绑定数组“type(&)[N]”转换为未知绑定数组“type(&)[]”? 2025-03-04 06:57:53 +0800 CST
  • Martin Hope
    Stefan Pochmann 为什么 {2,3,10} 和 {x,3,10} (x=2) 的顺序不同? 2025-01-13 23:24:07 +0800 CST
  • Martin Hope
    Chad Feller 在 5.2 版中,bash 条件语句中的 [[ .. ]] 中的分号现在是可选的吗? 2024-10-21 05:50:33 +0800 CST
  • Martin Hope
    Wrench 为什么双破折号 (--) 会导致此 MariaDB 子句评估为 true? 2024-05-05 13:37:20 +0800 CST
  • Martin Hope
    Waket Zheng 为什么 `dict(id=1, **{'id': 2})` 有时会引发 `KeyError: 'id'` 而不是 TypeError? 2024-05-04 14:19:19 +0800 CST
  • Martin Hope
    user924 AdMob:MobileAds.initialize() - 对于某些设备,“java.lang.Integer 无法转换为 java.lang.String” 2024-03-20 03:12:31 +0800 CST

热门标签

python javascript c++ c# java typescript sql reactjs html

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve