Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
是否可以将 spring 数据配置为返回通用错误消息而不是特定的 SQL 错误消息?
我问这个是因为我需要更改正在访问数据库的系统,并且当抛出错误时“放弃”太多数据库信息,例如:如数据库版本。
您可以将数据库查询包装在 try 语句中,然后在 catch 部分中使用记录器或其他方式输出自定义的通用错误消息。
您可以使用“instanceof”比较器进一步找出它是哪个异常。
这是您正在寻找的答案还是我误解了这个问题?