bus-error 相关问题


运行时错误:NCCL 错误 2:未处理的系统错误

我最近将cuda从9.0升级到10.2,但是当我成功升级时,我的演示如下,将默认出现“RuntimeError: NCCL Error 2: unhandled system error”。 我不知道为什么,而且...


使用 JS 和 PHP SQL 查询获取 JSON 数据

函数 fetchBooks() { fetch('圣经书.php') .then(响应=> { 如果(!response.ok){ throw new Error('网络响应不正常'); } 返回response.json(); ...


next.js 14 错误:无法读取未定义的属性(读取“get”)”

官方示例https://github.com/vercel/next.js/tree/canary/examples/next-forms在createTodo时出现错误“Error: Cannot readproperties of undefined (reading 'get')”。但是……


存储过程中非法混合排序规则

我的 MySQL 存储过程因 Mysql::Error: Illegal mix of collations (utf8_general_ci,IMPLICIT) and (utf8_unicode_ci,IMPLICIT) for operation '=' 而失败。 在 SELECT 子句中时该过程失败...


在php中通过另一个类常量定义类常量[重复]

如何根据同一类中的另一个常量定义一个类常量? A类{ const BASE_URL = 'http://example.org' 常量 API_URL = BASE_URL 。 '/api'; // < error }


如何测试Box中的错误类型<dyn Error>?

我有一个返回结果的函数<(), Box>。我正在为此函数编写一个测试用例,其中该函数应返回变体VerifyError::LinearCombination 的错误...


Angular 17 中的 NG 块 UI

我尝试在 Angular 17 中使用 NG Block UI 并收到此错误 ng block ui error in Angular 17 知道这个模块在 Angular 17 中如何工作吗? 提前致谢 我使用 npm i ng-


将 Xamarin UWP 应用程序升级到毛伊岛后,新更新拒绝安装

这几乎正是我所发生的事情:https://learn.microsoft.com/en-us/answers/questions/1000760/migrate-uwp-app-to-maui-windows-error-after-更新?评论=问题#最新问题-


为什么在Windows环境下Apache IoTDB中运行`pip install`后出现`failed to build thrift`错误?

pip install apache-iotdb工具不支持Windows环境吗?在Windows中运行pip install apache-iotdb==0.13.0.post1后,出现错误消息:Failed to build thrift, ERROR: Could ...


如何配置验证以对无效输入使用“is-invalid”类

默认情况下,ASP.NET Core 中的输入验证使用类 input-validation-error,但 Bootstrap 5 使用 is-invalid。 我找到了一些解决方案: 创建样式 使用 jQuery.validate.unobtrusi...


如何使用 Result lib 处理 Void 成功案例(成功/失败)

简介: 我在我的应用程序的某些地方引入了结果框架(反典型)。例如,给定这个函数: func findItem(byId: Int, 完成: (Item?,Error?) -> ()); foo.findI...


Javascript 删除堆栈跟踪字符串中的最后一项

我正在创建一个 Javascript 记录器,在错误消息中,我还添加了堆栈跟踪,如下所示: 函数 logMessage(logMessage) { 让 stackTrace = new Error().stack; 日志消息。


如何在 Angular 中导入其他组件的 config.ts 文件

按照本教程,我创建了一个可重用的模态组件。模态本身是从其他组件显示的(带有错误 ERROR TypeError: ctx_r1.modalConfig is undefined),但我不能


Spotify API {'error': 'invalid_client'} 授权代码流程 [400]

这是我向 https://accounts.spotify.com/api/token 发出 POST 请求的多次尝试之一。 范围设置为“播放列表修改公共、播放列表修改私有”。 我正在使用 Python 3.7,Djan...


Netflix dgs springboot UI http://localhost:8080/graphiql 不工作

尝试通过netflix-dgs实现graphql api。 获取资源未找到错误。 下面分享代码片段 出现以下错误 此应用程序没有 /error 的显式映射,因此您...


我在代码中遇到此错误:Swift/ContigeousArrayBuffer.swift:600: Fatal error: Index out of range

我正在构建一个测验应用程序,但收到此错误:Swift/ContigouslyArrayBuffer.swift:600:致命错误:索引超出范围。这是被标记的代码片段: choice2.setTitle(


必须提供 jwt 在 NextJs 13 中出现错误

我得到的错误是:data: { error: '必须提供jwt' } 当用户通过提供正确的电子邮件和密码登录时,用户将被重定向 到“/”页逻辑被写入...


Traefik 卡在重启中,不清楚的错误

我正在尝试在 docker compose 中运行 traefik 图像,它之前可以正常工作,但自从我拉取图像后,我从 docker compose log traefik 获得的唯一日志是 command traefik error: field not


ESLint 错误:带有建议的规则必须将 `meta.hasSuggestions` 属性设置为 `true`(无显式任何规则)

我正在尝试向 .eslintrc.json 添加规则以禁止任何类型。 我将规则 ("@typescript-eslint/no-explicit-any": "error") 添加到我的设置中: { “环境”:{ ...


如何从日期中截断时间并将其传递给组件?

我有这个问题: 从后端我得到格式为的日期:2022-05-20 (LocalDate) 当我想编辑表单上的日期时,出现错误:Internal Server Error Text '2023-04-29T22:00:00.0...


Flutter Firebase 初始化:Android 上的 PlatformException(null-error)

我正在开发适用于 Android 的 Flutter 应用程序,并在初始化 Firebase 时遇到问题。尽管遵循标准设置程序,但我在运行应用程序时不断收到错误。 错误描述:


将连接的字符串发送到函数并仅返回 Result::Error

我有一个带有一些函数的结构,当出现问题时,我调用函数 fn set_error(&self,msg:&str) 来记录错误并可能显示错误消息等。 目前这是 v...


检查结果中选项内的值是否满足 Rust 条件的最佳方法是什么?

我有一个返回 Result、Error> 之类的函数,我想检查是否存在值以及它是否与条件匹配。有两种简单的方法: 如果...


如何编写类型安全的函数签名来接受 amplify-js v6 graphql 订阅通知的回调函数?

使用版本 6.0.9 的 NPM 库 aws-amplify (不是 5.x.x!),我尝试将调用包装到 client.graphql({ query: typedGqlString, Variables}).subscribe({ next, error }),这样我就可以治疗...


Redhat Openshift 部署配置已停止工作并出现“Crashloop backoff error”[已关闭]

我们使用 RedHat Openshift 来托管和部署我们的应用程序。 一切都工作正常,直到最近使用 DeploymentConfig 的部署刚刚开始抛出“崩溃循环退避...


'。'宏参数列表中出现意外,在`#define error(args...)`中

我在 C++ 中使用这个定义来调试我的变量,它在 clion 和 codeblocks 中工作,但在 Visual Studio 22 中不起作用。 错误 C2010 '.':宏参数列表 codeforces 中出现意外 文件名是&


共享在 Rust 中实现 Trait 的对象

我有一个对象特征,可以从某个索引提供字节。这些可能是文件、正在跟踪的进程、其他字节提供程序上的缓存等: 使用 std::结果::结果; 使用 std::io::Error ;


具有多个数据库的 postgresql 上的 Symfony 6 学说问题 SQLSTATE[42P01]:未定义的表:7 ERROR

我的 Symfony 项目(sf v6)使用 postgresql/postgis 和 2 个数据库:主要一个包含特定业务数据,第二个称为 Web 服务数据库,其中多个共享数据


预呈现页面“/”时发生错误。阅读更多:https://nextjs.org/docs/messages/prerender-error 修改请求(不知道如何)

已经四天了,我仍然陷入困境。 关于这个问题我看到有人说使用axios,并设置超时。或者在获取数据时将 http 更改为 https,但这一切都是徒劳的...


嵌套 useFetch 导致 Nuxt 3 中的 Hydration 节点不匹配

在 Nuxt 3 页面内,我通过从 pinia 存储调用操作来获取帖子数据: {{ 发布数据 }} {{ 帖子内容... 在 Nuxt 3 页面内,我通过从 pinia 商店调用操作来获取帖子数据: <template> <div v-if="postData && postContent"> {{ postData }} {{ postContent }} </div> </template> <script setup> const config = useRuntimeConfig() const route = useRoute() const slug = route.params.slug const url = config.public.wpApiUrl const contentStore = useContentStore() await contentStore.fetchPostData({ url, slug }) const postData = contentStore.postData const postContent = contentStore.postContent </script> 那是我的商店: import { defineStore } from 'pinia' export const useContentStore = defineStore('content',{ state: () => ({ postData: null, postContent: null }), actions: { async fetchPostData({ url, slug }) { try { const { data: postData, error } = await useFetch(`${url}/wp/v2/posts`, { query: { slug: slug }, transform(data) { return data.map((post) => ({ id: post.id, title: post.title.rendered, content: post.content.rendered, excerpt: post.excerpt.rendered, date: post.date, slug: post.slug, })); } }) this.postData = postData.value; if (postData && postData.value && postData.value.length && postData.value[0].id) { const {data: postContent} = await useFetch(`${url}/rl/v1/get?id=${postData.value[0].id}`, { method: 'POST', }); this.postContent = postContent.value; } } catch (error) { console.error('Error fetching post data:', error) } } } }); 浏览器中的输出正常,但我在浏览器控制台中收到以下错误: entry.js:54 [Vue warn]: Hydration node mismatch: - rendered on server: <!----> - expected on client: div at <[slug] onVnodeUnmounted=fn<onVnodeUnmounted> ref=Ref< undefined > > at <Anonymous key="/news/hello-world()" vnode= {__v_isVNode: true, __v_skip: true, type: {…}, props: {…}, key: null, …} route= {fullPath: '/news/hello-world', hash: '', query: {…}, name: 'news-slug', path: '/news/hello-world', …} ... > at <RouterView name=undefined route=undefined > at <NuxtPage> at <Default ref=Ref< undefined > > at <LayoutLoader key="default" layoutProps= {ref: RefImpl} name="default" > at <NuxtLayoutProvider layoutProps= {ref: RefImpl} key="default" name="default" ... > at <NuxtLayout> at <App key=3 > at <NuxtRoot> 如何解决这个问题? 我尝试在 onMounted 中获取帖子数据,但在这种情况下 postData 和 postContent 保持为空 onMounted(async () => { await contentStore.fetchPostData({ url, slug }) }) 您可以使用 ClientOnly 组件来消除该警告。请参阅文档了解更多信息。 该组件仅在客户端渲染其插槽。


我无法用vue.js显示json

我需要使用 v-for 显示 json 中的产品数组,但我无法这样做。 我正在尝试显示产品数组中的 json 数据,但它不起作用。 Vue.js 我需要使用 v-for 显示 json 中的产品数组,但我无法这样做。 我正在尝试显示产品数组中的 json 数据,但它不起作用。 Vue.js <div class="box" v-for="product in products" :key="product.id"> <h2>Produto {{ product.name }}</h2> <h3>Situação {{ product.situation }}</h3> </div> export default { data() { return { products: [], }; }, methods: { async getData() { try { const req = await fetch("http://localhost:3000/products"); const data = await req.json(); this.products = data.products; console.log("data" + data); } catch (error) { console.error("Error fetching data:", error); } }, mounted() { this.getData(); }, }, }; JSON: { "products": [ { "id": "a898", "name": "Claudio Romano", "situation": "Ativo" } ] } 您问错了问题,因为该问题与 JSON 无关。如果您对此进行调试,您会注意到 console.logs 不执行,这意味着问题更为根本,因为该方法本身并未实际运行。 根本问题是mounted()不应该在methods内部。您正在使用 Vue 的选项 API,其中 data()、methods 和 mounted 都是独立的、单独的“选项”。您需要将安装移动到方法之外,它应该是一个“兄弟”选项。 export default { data() { ... }, methods: { ... }, mounted() { this.getData(); }, }; 游乐场演示


为什么每次我尝试将应用程序从 Anypoint Studio 部署到 CloudHub 时,我的 pom.xml 文件都会更新?

我的 pom.xml 文件中有以下部分用于我正在执行的虚拟项目: org.mule.tools.maven mule-maven-插件 我正在做的一个虚拟项目的 pom.xml 文件中有以下部分: <plugin> <groupId>org.mule.tools.maven</groupId> <artifactId>mule-maven-plugin</artifactId> <version>${mule.maven.plugin.version}</version> <extensions>true</extensions> <configuration> <classifier>mule-application</classifier> </configuration> </plugin> 每当我尝试直接从 Studio 将应用程序部署到 CloudHub 时,上面的部分就会更改为以下部分: <plugin> <groupId>org.mule.tools.maven</groupId> <artifactId>mule-maven-plugin</artifactId> <version>${mule.maven.plugin.version}</version> <extensions>true</extensions> <configuration> <classifier>---- select project type ----</classifier> </configuration> </plugin> 然后部署失败并出现以下错误: Publication status: error [INFO] ------------------------------------------------------------ [INFO] Steps: [INFO] - Description: Publishing asset [INFO] - Status: error [INFO] - Errors: [The asset is invalid, Error while trying to set type: app. Expected type is: rest-api.] [INFO] ......................................... [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 02:33 min [INFO] Finished at: 2024-01-08T14:11:31+05:30 [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.mule.tools.maven:exchange-mule-maven-plugin:0.0.17:exchange-deploy (default-exchange-deploy) on project super-biodata-sapi: Exchange publication failed: Publication ended with errors: [The asset is invalid, Error while trying to set type: app. Expected type is: rest-api.] -> [Help 1] 这可能是什么原因? 以下是一些细节: Anypoint Studio版本:7.16.0 Maven版本:3.8.8 Mule 运行时版本:4.4.0 Mule Maven 插件版本:3.8.0/4.0.0(两者都尝试过) Java版本:OpenJDK 11.0.9 我以前使用过 Anypoint Studio 7.15,在那里完全相同的项目没有任何问题。但更新后,我遇到了很多问题。 我还尝试使用“rest-api”而不是“mule-application”。然后,首先在部署开始时,“rest-api”更改为“mule-application”,然后再次更改为“----选择项目类型----”,最后失败。 我怀疑存在混乱。您提到您正在尝试将 Mule 4 应用程序部署到 CloudHub,但对资产的引用和错误消息与将资产发布到 Any point Exchange 相关。 CloudHub是一个部署和执行Mule应用程序的云平台。 Anypoint Exchange 是资产存储库,包括 REST API 的定义,但不包括 Mule 4 应用程序,也不用于执行任何操作。有关有效资产的详细信息,请参阅文档。 由于 mule-application 不是发布到 Exchange 的有效资产类型(对于 Mule 4),那么 Studio 似乎试图让您更改为有效的资产类型。 如果您尝试部署到 CloudHub,请参阅文档了解不同的方法。


如何在不重新加载页面的情况下发送带有文件的表单?

我尝试在ajax中发送表单而不重新加载页面,但我看到,文件上的链接不存在...... 我有下一个表格: 我尝试在ajax中发送表单而不重新加载页面,但我看到,文件上的链接不存在... 我有下一个表格: <form id="settings" method="POST" enctype="multipart/form-data"> ... <input type="file" id="logo" style="display:none;" name="logo" accept="image/png, image/jpeg, image/gif"> <button type="submit" id="send" class="btn btn-primary">save</button> </form> Ajax 脚本: $('#settings').submit(function(e){ e.preventDefault(); var form = $(this).serialize(); alert(form); // file is not attached... $.ajax({ url : '/settings', type : 'POST', crossDomain : false, data : form, contentType : 'multipart/form-data', dataType : 'json', progressData: false, cache : false, success : function(r){ alert (111); } }).fail(function(){ console.log('Error occured!'); }); }); 在服务器端,我收到错误: org.apache.tomcat.util.http.fileupload.FileUploadException:请求被拒绝,因为未找到多部分边界 我尝试不序列化表单,而是写了 data : form -> data : new FormData(this) 此选项会导致错误“非法调用”。如何在不重新加载页面的情况下发送带有文件的表单? 要使用 AJAX 发送带有文件的表单而不重新加载页面,您需要使用 FormData 来正确处理文件上传。 <form id="settings" method="POST" enctype="multipart/form-data"> <!-- Other form fields --> <input type="file" id="logo" name="logo" accept="image/png, image/jpeg, image/gif"> <button type="submit" id="send" class="btn btn-primary">Save</button> </form> $(document).ready(function() { $('#settings').submit(function(e){ e.preventDefault(); var formData = new FormData(this); $.ajax({ url: '/settings', type: 'POST', data: formData, contentType: false, processData: false, cache: false, success: function(response){ alert('Form submitted successfully!'); // Handle the response from the server }, error: function(){ console.log('Error occurred!'); } }); }); });


表单响应:“无法处理请求 HTTP ERROR 500”。我做错了什么?

我尝试在网站上编写 php 表单,但收到错误 500。我无法弄清楚我做错了什么。你能看一下代码看看我做错了什么吗? PHP: 我尝试在网站上编写 php 表单,但收到错误 500。我无法弄清楚我做错了什么。你能看一下代码看看我做错了什么吗? PHP: <?php // define variables and set to empty values $name = $email = $phone = $enquiry = ""; if ( $_SERVER[ "REQUEST_METHOD" ] == "POST" ) { if ( empty( $_POST[ "name" ] ) ) { $nameErr = "Name is required"; } else { $name = test_input( $_POST[ "name" ] ); // check if name only contains letters and whitespace if ( !preg_match( "/^[a-zA-Z-' ]*$/", $name ) ) { $nameErr = "Only letters and white space allowed"; } } if ( empty( $_POST[ "email" ] ) ) { $emailErr = "Email is required"; } else { $email = test_input( $_POST[ "email" ] ); // check if e-mail address is well-formed if ( !filter_var( $email, FILTER_VALIDATE_EMAIL ) ) { $emailErr = "Invalid email format"; } } if ( empty( $_POST[ "phone" ] ) ) { $comment = ""; } else { $comment = test_input( $_POST[ "phone" ] ); } if ( empty( $_POST[ "enquiry" ] ) ) { $comment = ""; } else { $comment = test_input( $_POST[ "enquiry" ] ); } } // Create the email and send the message $destination = "[email protected]"; $subject = "Website Contact Form Enquiry: $name"; $body = "You have received a new message from your website contact form.\\n\\n"."Here are the details:\\n\\nName: $name\\n\\nEmail: $email\\n\\nPhone: $phone\\n\\nEnquiry:\\n$enquiry"; $header = "From: [email protected]\\n"; $headers = array(); $headers[] = "MIME-Version: 1.0"; $headers[] = "Content-type: text/plain; charset=iso-8859-1"; $headers[] = "From: " . $fromAddress; $headers[] = "Subject: " . $subject; $headers[] = "X-Mailer: PHP/".phpversion(); mail($destination, $subject, $message, implode("\r\n", $headers)); // mail($to,$subject,$msg,$headers); echo "Email successfully sent."; ?> HTML 格式: <form id="contact-form" method="post" action="/contact.php" role="form"> <div class="messages"></div> <div class="controls"> <div class="row"> <div class="col-md-10"> <div class="form-group"> <input id="form_name" type="text" name="name" class="form-control" placeholder="Name*" required="required" data-error="Your name is required." > <div class="help-block with-errors"></div> </div> </div> <div class="col-md-10"> <div class="form-group"> <input id="form_email" type="email" name="email" class="form-control" placeholder="Email*" required="required" data-error="Valid email is required." > <div class="help-block with-errors"></div> </div> </div> <div class="col-md-10"> <div class="form-group"> <input id="form_phone" type="text" name="phone" class="form-control" placeholder="Phone" > <div class="help-block with-errors"></div> </div> </div> </div> <div class="row"> <div class="col-md-10"> <div class="form-group"> <textarea id="form_enquiry" name="enquiry" class="form-control" placeholder="Enquiry*" rows="6" required="required" data-error="Please, leave us a message."></textarea> <div class="help-block with-errors"></div> </div> </div> <div class="col-md-12"> <input class="btn btn-large btn-primary centre mt-10" type="submit" value="Submit" > </div> </div> </div> </form> 我已按照其他人的指示使表单正常工作,但所做的更改仍然会出现错误。 这是一个简单的形式,但我似乎对我做错了什么缺乏了解。 请帮助我。 如果您查看发送邮件的行,这是一个硬行结尾,将 $headers 推到新行上吗?这将调用 500 错误。 查看 /var/log/apache2/error.log(如果您使用的是 Debian)或 /var/log/httpd/error.log(如果使用的是 RHEL 或类似系统)。 您的代码存在许多问题,但首先关注快乐的道路,然后让事情正常运行。


IIS Rewrite 在重写到外部网站时始终返回 502 bad gateway

是一个部署在IIS上的小网站。我正在使用此网站上的重写功能来重写对外部网站的 http 请求。这是 web.config 中的重写设置。 是一个部署在IIS上的小网站。我正在使用此网站上的重写功能来重写对外部网站的 http 请求。这是 web.config 中的重写设置。 <system.webServer> <rewrite> <rules> <rule name="ReverseProxyInboundRule1" stopProcessing="true"> <match url="(.*)" /> <action type="Rewrite" url="https://about.gitlab.com/" logRewrittenUrl="true" /> </rule> </rules> </rewrite> </system.webServer> 它总是返回HTTP Error 502.2 - Bad Gateway。 HTTP 错误 502.2 - 网关错误 尝试路由请求时出现连接错误。 如果我只是使用指向此网站内页面的内部路径,使用相对路径,以 / 开头,那么它就可以正常工作。改成外部网站后,总是返回HTTP Error 502.2 - Bad Gateway。 有什么地方需要更新吗? 这是我解决问题的方法。它可能不是所有502 bad gateway问题的解决方案,但它解决了我的问题。 在应用程序请求路由 -> 缓存设置 -> 内存缓存持续时间中。我把他的值设置为0。然后它就按预期工作了。


错误 2911:无法删除文件夹 C:\Config.Msi\

我有一个创建桌面快捷方式的安装: 我的安装会创建桌面快捷方式: <Shortcut Id="SC.Desktop" Directory="DesktopFolder" Name="!(bind.Property.ProductName)" WorkingDirectory="INSTALLDIR" Target="[INSTALLDIR]testfile.txt" /> <RegistryValue Root="HKCU" Key="Software\[Manufacturer]\[ProductName]" Type="integer" Name="DesktopIcon" Value="1" KeyPath="yes" /> 安装后一切正常,详细日志中没有错误。 在卸载时,我在详细日志中收到错误: DEBUG: Error 2911: Could not remove the folder C:\Config.Msi\. 如何解决这个问题? 这不是真正的错误消息。这只是 Windows 安装程序在自言自语。类似的文件和文件夹通常会在重新启动时清理。


Angular Material 2:修复多行错误消息

我在我的角度应用程序中使用角度材料2。当我的表单输入字段错误消息超过一行时,我遇到了问题。这是照片: 这是代码: 我在我的角度应用程序中使用角度材料 2。当我的表单输入字段错误消息超过一行时,我遇到了问题。这是照片: 这是代码: <md-error *ngIf="password.touched && password.invalid"> <span *ngIf="password.errors.required"> {{'PASSWORD_RECOVERY.FIELD_REQUIRED' | translate}} </span> <span *ngIf="password.errors.minlength || password.errors.maxlength"> {{'PASSWORD_RECOVERY.PASSWORD_LENGTH' | translate}} </span> <span *ngIf="password.errors.pattern"> {{'PASSWORD_RECOVERY.FOR_A_SECURE_PASSWORD' | translate}} </span> </md-error> 我通过阅读 github 了解到,这是 Angular 2 材料中的一个错误。有人通过自定义解决方法成功解决了这个问题吗? 问题是类为 .mat-form-field-subscript-wrapper 的元素是 position: absolute,所以它不占用实际空间。 按照 xumepadismal 在 github 上关于此问题的建议,您可以添加此 scss 作为解决我的问题的解决方法: // Workaround for https://github.com/angular/material2/issues/4580. mat-form-field .mat-form-field { &-underline { position: relative; bottom: auto; } &-subscript-wrapper { position: static; } } 它会转换静态 div 中的 .mat-form-field-subscript-wrapper 节点,并将 .mat-form-field-unterline 重新定位在输入字段之后。 正如材料 15 中在 github 讨论中提到的,可以通过将 subscriptSizing="dynamic" 添加到 mat-form-field 来解决问题。 要更改默认行为,您必须使用以下选项更新 angular.module.ts 提供程序: providers: [ { provide: MAT_FORM_FIELD_DEFAULT_OPTIONS, useValue: { subscriptSizing: 'dynamic' } } ] 这也可以在材料文档中找到 使用@mattia.corci提出的解决方案会导致错误消息被推到底部太多,从而在顶部留下不必要的空白空间。 使用 Tailwind CSS,这个解决方案对我来说适用于最新的 Angular 17: .mat-mdc-form-field { @apply w-full self-start; .mat-mdc-form-field-subscript-wrapper { @apply flex; .mat-mdc-form-field-error-wrapper { @apply static; } } } mat-form-field.ng-invalid.ng-touched { animation: example; animation-duration: 0.3s; margin-bottom: 20px; } @keyframes example { from { margin-bottom: 0; } to { margin-bottom: 20px; } } 它对我有用。


错误 | prefect.flow_runs.runner - 流程运行进程退出,状态代码:-7

我在运行脚本时收到此完美错误。错误如下: 0%| | 0/2070 [00:00 我在运行脚本时收到此完美错误。错误如下: 0%| | 0/2070 [00:00<?, ?it/s]09:36:01.917 | ERROR | prefect.flow_runs.runner - Process for flow run 'auspicious-butterfly' exited with status code: -7 09:36:02.057 | INFO | prefect.flow_runs.runner - Reported flow run '1f314ccd-1472-4373-bb1b-4b3b6265b29a' as crashed: Flow run process exited with non-zero status code -7. 不知道为什么。任何帮助将不胜感激。 我和 Prefect 也有同样的错误。您有什么版本的 Prefect? Reported flow run 'bbaa6e16-bf5f-44ff-a31b-d68645f74bb1' as crashed: Flow run process exited with non-zero status code -7. Process for flow run 'xi5-zeon' exited with status code: -7


内置布尔到可见性转换器无法编译

我正在尝试使用自动 IReference 到可见性转换将可见性绑定到 ToggleButton::IsChecked 我正在尝试使用自动 IReference 到可见性转换将可见性绑定到 ToggleButton::IsChecked <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center"> <CheckBox x:Name="myButton" Content="Click Me" /> <TextBlock Text="Hello" Visibility="{x:Bind myButton.IsChecked, Mode=OneWay}"/> </StackPanel> 在空白项目中这是可行的。在我现有的项目中,如果我提供自己的转换器,它就会工作,但如果我尝试使用自动转换,我会得到: error C3779: 'winrt::impl::consume_Windows_Foundation_IReference< winrt::Windows::Foundation::IReference<bool>,T>::Value': a function that returns 'auto' cannot be used before it is defined with [ T=bool ] (compiling source file Generated Files\XamlTypeInfo.g.cpp) 如果针对 c++17 进行编译,错误就会消失。我正在为 c++20 编译 https://github.com/microsoft/microsoft-ui-xaml/issues/9214


如何使用 Microsoft Graph API 解决 Sharepoint(FileContentRead) 中的 404 -“ItemNotFound”错误?

我使用下面的 API 使用 Microsoft Graph API 从 Sharepoint 读取其内容。 https://graph.microsoft.com/v1.0/sites/{主机名},{spsite-id},{spweb-id}/drives//items/ 我使用下面的 API 使用 Microsoft Graph API 从 Sharepoint 读取其内容。 https://graph.microsoft.com/v1.0/sites/{hostname},{spsite-id},{spweb-id}/drives/<drive-id>/items/<items-id>/content 两天前,它正确地从根站点正确获取文件内容。但今天我检查了是否获得了与以下问题相同的文件内容。 { "error": { "code": "itemNotFound", "message": "Item not found", "innerError": { "request-id": "<request_id>", "date": "<date_time>" } } } 不知道这可能是什么原因造成的?我在谷歌上搜索没有找到更好的解决方案。 有人建议我解决上述问题的方法。 我建议使用此端点下载流式 DriveItem 内容: GET /sites/{siteId}/drive/items/{item-id}/content https://learn.microsoft.com/en-us/graph/api/driveitem-get-content?view=graph-rest-1.0&tabs=http


使用 JavaScript 以 HTML 形式显示 Google 云端硬盘中的图像时遇到问题

我正在努力使用 JavaScript 在我的 HTML 页面上显示来自 Google Drive 的图像。遵循在线指南并没有完全解决我的问题。 HTML(索引.html): 我正在努力使用 JavaScript 在我的 HTML 页面上显示来自 Google 云端硬盘的图像。遵循在线指南并没有完全解决我的问题。 HTML(index.html): <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Google Drive Image</title> </head> <body> <img id="imageElement" alt="A lovely image"> <script src="script.js"></script> </body> </html> JavaScript(script.js): const fileId = '1BEW9tkgVKlp_ebUc17LkXDH-mnPc4ome'; const imageElement = document.getElementById('imageElement'); async function fetchGoogleDriveImage(fileId) { try { const response = await fetch(`https://drive.google.com/uc?id=${fileId}`); const url = URL.createObjectURL(await response.blob()); imageElement.src = url; } catch (error) { console.error('Error fetching the image:', error); } } fetchGoogleDriveImage(fileId); 背景: Google 云端硬盘中的图像设置为“知道链接的任何人都可以查看。” 尽管如此,图像仍无法在浏览器中加载,并且控制台显示错误。 附加HTML(纯html): <body> <img src="https://drive.google.com/uc?id=1BEW9tkgVKlp_ebUc17LkXDH-mnPc4ome" alt="Your Image Alt Text"> </body> CodePen 示例 如有任何帮助,我们将不胜感激!谢谢。 虽然没有在任何地方发布(我发现),但 Google Drive 的服务器已开始拒绝附加这两个标头的请求: sec-fetch-mode: no-cors sec-fetch-site: cross-site 如果您将浏览器直接导航到文件的(直接链接)URL(即获取您的src URL并将其粘贴到浏览器导航栏中),但该请求期间的sec-fetch-mode标头将是设置为 navigate 并且效果很好。 但是,与您的 <img> 示例一样,如果请求源是网页,并且与 drive.google.com 来源不同,就会出现问题。 (您的浏览器将自动将这些 sec-fetch-mode 和 sec-fetch-site 标头设置为请求的一部分。) 这似乎是 Google Drive 自 2024 年 1 月 10 日开始的一项未记录的更改,我仍然找不到任何提及它的地方,因此尚不清楚此行为是否会持续存在,或者是否反映了意外更改或疏忽。 我也有同样的问题。临时解决办法是使用大宽度的驱动器文件缩略图 您正在此处执行所有操作,看来问题出在 Google 端,并于今天开始发生(撰写本文时为 2024 年 1 月 11 日)。 Google 可能会解决此问题并允许直接图像嵌入,或者他们可能会继续阻止它,这意味着您必须找到另一种方式来托管网站图像,例如 S3。 (可能)此处跟踪错误:https://issuetracker.google.com/issues/319531488?pli=1 我开始在 HTML 中链接 css 文件时遇到同样的问题。


带斜杠的边框半径在 React-pdf 中不起作用

我知道我们可以在CSS中为半圆设置border-radius: 4px/2px。 但它在 React pdf 中不起作用。 我尝试过这些。 我知道我们可以在CSS中为半圆设置border-radius: 4px/2px。 但它在 React pdf 中不起作用。 我尝试过这些。 你好 我导入了所有 React pdf 元素。但是当我尝试上述设计时,我在控制台中收到错误。 错误是 @react-pdf_renderer.js?v=e8b1cced:113701 Error: unsupported number: NaN at number2 (@react-pdf_renderer.js?v=e8b1cced:58798:11) at PDFDocument2.lineTo (@react-pdf_renderer.js?v=e8b1cced:59998:28) at clipNode2 (@react-pdf_renderer.js?v=e8b1cced:32924:7) at renderBackground3 (@react-pdf_renderer.js?v=e8b1cced:34087:5) at renderNode3 (@react-pdf_renderer.js?v=e8b1cced:34139:3) at renderChild2 (@react-pdf_renderer.js?v=e8b1cced:34123:12) at Array.forEach (<anonymous>) at renderChildren2 (@react-pdf_renderer.js?v=e8b1cced:34125:12) at renderNode3 (@react-pdf_renderer.js?v=e8b1cced:34145:5) at renderChild2 (@react-pdf_renderer.js?v=e8b1cced:34123:12) 有人可以帮忙吗 测试此类语法的最简单方法是在 repl 中https://react-pdf.org/repl 简短的回答是 4px/2 不是单个 px 值,因此 = NAN 使用任何其他单个愚蠢的数字即可。


如何在 Abap Simple Transformation 中添加 XML 命名空间

我使用简单转换从内部表中获取 XML。这是输出 XML。 我使用简单转换从内部表中获取 XML。这是输出 XML。 <?xml version="1.0" encoding="UTF-8"?> <Complement> <Document Doc="AAA"> <Locations> <Location> <Origin RFC="URE180429TM6"/> <Address Country="SOME_COUNTRY" /> [....] </Location> </Locations> <Products NumTotal="1"> <Product ValorProduct="12164501" /> [....] </Product> </Products> [....].... </Document> </Complement> 但是现在我需要做的是更改一些 XML 元素名称(重命名它们)..这应该使我的 XML 看起来像这样: 例如,我需要第一个元素(补语)看起来像 cfdi:Complement (在 cfdi 和补语之间使用冒号 :)...等等等等 <cfdi:Complement> <document:Document Doc="AAA"> <document:Locations> <document:Location> <document:Origin RFC="URE180429TM6"/> <document:Domicilio Country="NIGERIA" /> [....] </document:Location> </document:Locations> <document:Products NumTotal="1"> <document:Product ValorProduct="12164501" /> [....] </document:Product> </document:Products> [....].... </document:Document> </cfdi:Complement> 我一直在尝试直接从简单转换代码更改元素名称,但它不起作用: <?sap.transform simple?> <tt:transform xmlns:tt="http://www.sap.com/transformation-templates" xmlns:ddic="http://www.sap.com/abapxml/types/dictionary" xmlns:def="http://www.sap.com/abapxml/types/defined"> <tt:root name="COMPLEMENT" type="ddic:ZCOMPLEMENT"/> <tt:template> <tt:namespace name="cfdi"/> <tt:namespace name="document"/> <cfdi:Complement> "<----- I get error from this lines <document:Document> "<----- I get error from this lines <tt:attribute name="Doc" value-ref=".COMPLEMENT.DOCUMENT.DOC"/> <document:Locations> <Location> <Origin> <tt:attribute name="RFC" value-ref=".COMPLEMENT.DOCUMENT.LOCATIONS.LOCATION.ORIGIN.RFC"/> [....] </Origin> <Address> <tt:attribute name="Country" value-ref=".COMPLEMENT.DOCUMENT.LOCATIONS.LOCATION.ADDRESS.COUNTRY"/> [....] </Address> </Location> </Locations> <Products> <tt:attribute name="NumTotal" value-ref=".COMPLEMENT.DOCUMENT.PRODUCTS.NUMTOTAL"/> <Product> <tt:attribute name="ValorProduct" value-ref="VALORPRODUCT"/> [....] </Product> </Products> [....].... </Document> </Complement> </tt:template> </tt:transform> 这些是我得到的错误: undeclared namespace prefix 'cfdi' 和 undeclared namespace prefix 'document' 这是简单的转换代码: 我只需要更改Element的名称即可。但我不认为这比看起来更难。 请帮我解决这个问题。我是这个 Abap 世界的新人。或者任何想法都会对我有很大帮助。问候 我之前遇到过一些命名空间问题,也许这个线程有帮助。 这是参考代码。正如您所看到的,您必须定义名称空间并按定义方式使用它,此处为 ns1。 <tt:template> <top_element xmlns:ns1="xsd/namespacesForBoxes" xmlns:ns2="xsd/namespacesForCartons" xmlns:ns3="xsd/namespacesForPallets"> <tt:namespace name="ns1"/> <tt:namespace name="ns2"/> <tt:namespace name="ns3"/> <tt:cond s-check="not-initial(ref('.telegram.BOX_ID'))"> <ns1:container> <tt:attribute name="box-id" value-ref=".telegram.BOX_ID"/> </ns1:container> </tt:cond> <tt:cond s-check="not-initial(ref('.telegram.CARTON_ID'))"> <ns2:container> <tt:attribute name="carton-id" value-ref=".telegram.CARTON_ID"/> </ns2:container> </tt:cond> <tt:cond s-check="not-initial(ref('.telegram.PALLET_ID'))"> <ns3:container> <tt:attribute name="pallet-id" value-ref=".telegram.PALLET_ID"/> </ns3:container> </tt:cond> </top_element> </tt:template> 之后应该是这样的: <top_element xmlns:ns1="xsd/namespacesForBoxes" xmlns:ns2="xsd/namespacesForCartons" xmlns:ns3="xsd/namespacesForPallets"> <ns1:container box-id="BOX"/> <ns2:container carton-id="CARTON"/> <ns3:container pallet-id="PALLET"/> </top_element> “tt:cond”只是为了让丢失的 XML 标签或不同顺序的标签不会扰乱你的转换。


SecurityException:不允许启动服务Intent { act=com.google.android.c2dm.intent.REGISTER pkg=com.google.android.gms (有额外功能)}

我尝试从 Google 获取我的 GCM 注册 ID。 我的代码: 字符串SENDER_ID =“722*****53”; /** * 向 GCM 服务器异步注册应用程序。 * * 存储注册信息... 我尝试从 Google 获取我的 GCM 注册 ID。 我的代码: String SENDER_ID = "722******53"; /** * Registers the application with GCM servers asynchronously. * <p> * Stores the registration ID and the app versionCode in the application's * shared preferences. */ private void registerInBackground() { new AsyncTask<Void, Void, String>() { @Override protected String doInBackground(Void... params) { String msg = ""; try { if (gcm == null) { gcm = GoogleCloudMessaging.getInstance(context); } regid = gcm.register(SENDER_ID); msg = "Device registered, registration ID=" + regid; // You should send the registration ID to your server over // HTTP, so it // can use GCM/HTTP or CCS to send messages to your app. sendRegistrationIdToBackend(); // For this demo: we don't need to send it because the // device will send // upstream messages to a server that echo back the message // using the // 'from' address in the message. // Persist the regID - no need to register again. storeRegistrationId(context, regid); } catch (IOException ex) { msg = "Error :" + ex.getMessage(); // If there is an error, don't just keep trying to register. // Require the user to click a button again, or perform // exponential back-off. } return msg; } @Override protected void onPostExecute(String msg) { mDisplay.append(msg + "\n"); } }.execute(null, null, null); } 我收到错误: 03-01 19:15:36.261: E/AndroidRuntime(3467): FATAL EXCEPTION: AsyncTask #1 03-01 19:15:36.261: E/AndroidRuntime(3467): java.lang.RuntimeException: An error occured while executing doInBackground() 03-01 19:15:36.261: E/AndroidRuntime(3467): at android.os.AsyncTask$3.done(AsyncTask.java:299) 03-01 19:15:36.261: E/AndroidRuntime(3467): at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:352) 03-01 19:15:36.261: E/AndroidRuntime(3467): at java.util.concurrent.FutureTask.setException(FutureTask.java:219) 03-01 19:15:36.261: E/AndroidRuntime(3467): at java.util.concurrent.FutureTask.run(FutureTask.java:239) 03-01 19:15:36.261: E/AndroidRuntime(3467): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230) 03-01 19:15:36.261: E/AndroidRuntime(3467): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080) 03-01 19:15:36.261: E/AndroidRuntime(3467): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573) 03-01 19:15:36.261: E/AndroidRuntime(3467): at java.lang.Thread.run(Thread.java:841) 03-01 19:15:36.261: E/AndroidRuntime(3467): Caused by: java.lang.SecurityException: Not allowed to start service Intent { act=com.google.android.c2dm.intent.REGISTER pkg=com.google.android.gms (has extras) } without permission com.google.android.c2dm.permission.RECEIVE 03-01 19:15:36.261: E/AndroidRuntime(3467): at android.app.ContextImpl.startServiceAsUser(ContextImpl.java:1800) 03-01 19:15:36.261: E/AndroidRuntime(3467): at android.app.ContextImpl.startService(ContextImpl.java:1772) 03-01 19:15:36.261: E/AndroidRuntime(3467): at android.content.ContextWrapper.startService(ContextWrapper.java:480) 03-01 19:15:36.261: E/AndroidRuntime(3467): at com.google.android.gms.gcm.GoogleCloudMessaging.b(Unknown Source) 03-01 19:15:36.261: E/AndroidRuntime(3467): at com.google.android.gms.gcm.GoogleCloudMessaging.register(Unknown Source) 03-01 19:15:36.261: E/AndroidRuntime(3467): at com.example.gcm.DemoActivity$1.doInBackground(DemoActivity.java:177) 03-01 19:15:36.261: E/AndroidRuntime(3467): at com.example.gcm.DemoActivity$1.doInBackground(DemoActivity.java:1) 03-01 19:15:36.261: E/AndroidRuntime(3467): at android.os.AsyncTask$2.call(AsyncTask.java:287) 03-01 19:15:36.261: E/AndroidRuntime(3467): at java.util.concurrent.FutureTask.run(FutureTask.java:234) 03-01 19:15:36.261: E/AndroidRuntime(3467): ... 4 more 这是我的清单: <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.manyexampleapp" android:installLocation="preferExternal" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="11" android:targetSdkVersion="18" /> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.GET_ACCOUNTS" /> <uses-permission android:name="android.permission.WAKE_LOCK" /> <uses-permission android:name="com.example.manyexampleapp.c2dm.permission.RECEIVE" /> <uses-permission android:name="com.example.manyexampleapp.gcm.permission.C2D_MESSAGE" /> <permission android:name="com.example.manyexampleapp.gcm.permission.C2D_MESSAGE" android:protectionLevel="signature" /> <application android:name="com.zoomer.ifs.BaseApplication" android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" /> <activity android:name="com.zoomer.ifs.MainActivity" android:label="@string/app_name" android:configChanges="orientation|keyboardHidden|screenSize" android:launchMode="singleTop"> <!-- <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> --> </activity> <!-- PUSH --> <!-- WakefulBroadcastReceiver that will receive intents from GCM services and hand them to the custom IntentService. The com.google.android.c2dm.permission.SEND permission is necessary so only GCM services can send data messages for the app. --> <receiver android:name="com.example.gcm.GcmBroadcastReceiver" android:permission="com.google.android.c2dm.permission.SEND" > <intent-filter> <!-- Receives the actual messages. --> <action android:name="com.google.android.c2dm.intent.RECEIVE" /> <category android:name="com.example.manyexampleapp" /> </intent-filter> </receiver> <service android:name="com.example.gcm.GcmIntentService" /> <activity android:name="com.example.gcm.DemoActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <!-- DB --> <activity android:name="com.example.db.DbActivity" android:label="@string/app_name" > <intent-filter> </intent-filter> </activity> <activity android:name="com.example.http.RestGetActivity" android:label="@string/app_name" android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" > </activity> <activity android:name="com.example.fb.FacebookLoginActivity" android:label="@string/app_name" > <!-- <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> --> </activity> <activity android:name="com.example.http.SendFeedbackActivity" android:label="@string/app_name" > <!-- <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> --> </activity> <activity android:name="com.zoomer.general.SearchNearbyOffersActivity" android:label="@string/app_name" > <intent-filter> </intent-filter> </activity> <activity android:name="com.facebook.LoginActivity" android:label="@string/app_name" > <intent-filter> </intent-filter> </activity> <activity android:name="com.example.manyexampleapp.StoresListActivity" > <intent-filter> </intent-filter> </activity> <activity android:name="com.example.fb.ShareActivity" > <intent-filter> </intent-filter> </activity> <activity android:name="com.example.notifications.NotificationsActivity" > <intent-filter> </intent-filter> </activity> <activity android:name="com.example.fb2.no_use.MainActivity" > <intent-filter> </intent-filter> </activity> <activity android:name="com.zoomer.offers.OffersListActivity" > <!-- <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> --> </activity> <activity android:name="com.example.http.SearchNearbyOffersActivity" > <!-- <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> --> </activity> <service android:name="com.example.geo.LocationService" android:enabled="true" /> <receiver android:name="com.example.manyexampleapp.BootReceiver" > <intent-filter> <action android:name="android.intent.action.BOOT_COMPLETED" /> <action android:name="com.example.manyexampleapp.LocationService.LOCATION_BROAD_MSG" /> </intent-filter> </receiver> <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/app_id" /> </application> </manifest> 改变 <uses-permission android:name="com.example.manyexampleapp.c2dm.permission.RECEIVE" /> 到 <!-- This app has permission to register and receive data message. --> <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /> 您收到异常是因为您尚未定义所需的权限 如果应用程序开发后安装了播放服务, 可能会发生 com.google.android.c2dm.permission.RECEIVE 权限已被授予但 android 仍在抱怨同样的错误。 在这种情况下,您必须完全重新安装开发的应用程序才能使此权限发挥作用。 我认为你必须检查 Kotlin 版本兼容性。


将 props 传递给 nextjs 中的页面组件

我正在使用 nextjs 的 withlayout 函数为某些页面添加侧边栏。 导出类型 PageWithLayout = NextPage & { withLayout?:(页面:ReactElement)=> 我正在使用 nextjs 的 withlayout 函数为某些页面添加侧边栏。 export type PageWithLayout<P = {}, IP = P> = NextPage<P, IP> & { withLayout?: (page: ReactElement) => ReactNode; }; 这是我的使用方法: export const Interactions: PageWithLayout = () => { const [ getInteractions, { data: interactionData, fetchMore, variables, loading: isInteractionsLoading, error: isInteractionsError, }, ] = useGetInteractionsLazyQuery({ notifyOnNetworkStatusChange: true, fetchPolicy: "network-only", ssr: false, }); return ( <> <Box height={"100vh"}> </Box> </> ); }; Interactions.withLayout = (page: ReactElement) => { // how do I pass isInteractionsLoading as a prop to this component return <Layout>{page}</Layout>; }; export default Interactions; 我想要实现的是将 isInteractionsLoaded 和 isInteractionsError 作为属性传递给我的布局组件,以便我可以渲染这些状态。有没有一种方法可以实现此目的,而无需将布局组件移动到页面组件内? 创建一个包装组件的 React Context 提供程序可能是您使用的解决方案,如果您不想使用任何其他包或不想使用 redux 等更强大的工具,则可以使用。 但是在这里使用有点尴尬,具体取决于包含交互的组件树是什么样子。否则可以根据您的需要使用 _app 入口点。 示例上下文和用法 import React from 'react'; export const InteractionContext = React.createContext({ isInteractionsLoading: false, isInteractionsError: null, }); // parent component or _app if necessary const ProviderComponent = () => { return ( <InteractionContext.Provider value={{ isInteractionsLoading, isInteractionsError }}> <Interactions /> </InteractionContext.Provider> ); }; const Layout = ({ children }) => { const { isInteractionsLoading, isInteractionsError } = useContext(InteractionContext); // Now you can use isInteractionsLoading and isInteractionsError here // ... return <div>{children}</div>; };


Velocity 在 Spring Boot 中找不到模板资源

我使用 Velocity 模板引擎在我的 Spring boot 应用程序中使用电子邮件模板发送电子邮件实用程序。 当前的代码如下所示。 pom.xml: 我正在使用 Velocity 模板引擎在我的 Spring boot 应用程序中使用电子邮件模板发送电子邮件实用程序。 当前代码如下所示。 pom.xml: <dependency> <groupId>org.apache.velocity</groupId> <artifactId>velocity</artifactId> <version>1.7</version> </dependency> <dependency> <groupId>org.apache.velocity</groupId> <artifactId>velocity-tools</artifactId> <version>2.0</version> </dependency> 速度引擎 bean 配置: @Configuration public class VelocityConfig { @Bean public VelocityEngine velocityEngine() { VelocityEngine ve = new VelocityEngine(); ve.setProperty(RuntimeConstants.RESOURCE_LOADER, "classpath"); ve.setProperty("classpath.resource.loader.class", ClasspathResourceLoader.class.getName()); ve.init(); return ve; } } 电子邮件模板放置在 src/main/resources/email-templates/summary-email.vm <!DOCTYPE html> <head> <title>Summary</title> </head> <body> <h1>Claims Summary</h1> </body> </html> 放置在以下目录中: src ├── main │ ├── java │ │ └── com │ │ └── packageNameioot │ │ └── SpringBootApplication.java │ ├── resources │ │ ├── email-templates │ │ │ └── summary-email.vm │ │ └── application.properties 使用模板发送电子邮件的服务类: @Slf4j @Service @RequiredArgsConstructor public class EmailSummaryService { private final EmailConnector connector; private final VelocityEngine velocityEngine; public Mono<Void> sendFinanceClaimsRunEmailSummary(FinancePeriodRunEntity periodRunEntity, int successCount, int errorCount) { EmailDto emailDto = EmailDto.builder() .recipients(Set.of("[email protected]")) .subject("Claims summary") .body(createEmailBody()) .html(true) .build(); return connector.submitEmailRequest(emailDto); } private String createEmailBody() { VelocityContext context = new VelocityContext(); Template template = velocityEngine.getTemplate("email-templates/summary-email.vm"); StringWriter writer = new StringWriter(); template.merge(context, writer); return writer.toString(); } } 但是Velocity无法定位模板,出现以下错误。 ERROR velocity:96 - ResourceManager : unable to find resource 'email-templates/summary-email.vm' in any resource loader. org.apache.velocity.exception.ResourceNotFoundException: Unable to find resource 'email-templates/summary-email.vm' 属性应该这样设置: VelocityEngine ve = new VelocityEngine(); ve.setProperty(RuntimeConstants.RESOURCE_LOADER, "classpath"); ve.setProperty("resource.loader.classpath.class", ClasspathResourceLoader.class.getName()); 根据 Apache Velocity Engine 文档。


通过更少的 Java API 调用来映射 Google 云端硬盘内容的有效方法

大家好,我有一个代码,用于列出共享驱动器中存在的文件(以便稍后下载并创建相同的文件夹路径) 目前我做这样的事情: 哈希映射 大家好,我有一个代码,用于列出共享驱动器中存在的文件(以便稍后下载并创建相同的文件夹路径) 目前我正在做这样的事情: HashMap<String, Strin> foldersPathToID = new HashMap<>(); //searching all folders first saving their IDs searchAllFoldersRecursive(folderName.trim(), driveId, foldersPathToID); //then listing files in all folders HashMap<String, List<File>> pathFile = new HashMap<>(); for (Entry<String, String> pathFolder : foldersPathToID.entrySet()) { List<File> result = search(Type.FILE, pathFolder.getValue()); if (result.size() > 0) { String targetPathFolder = pathFolder.getKey().trim(); pathFile.putIfAbsent(targetPathFolder, new ArrayList<>()); for (File file : result) { pathFile.get(targetPathFolder).add(file); } } } 递归方法在哪里: private static void searchAllFoldersRecursive(String nameFold, String id, HashMap<String, String> map) throws IOException, RefreshTokenException { map.putIfAbsent(nameFold, id); List<File> result; result = search(Type.FOLDER, id); // dig deeper if (result.size() > 0) { for (File folder : result) { searchAllFoldersRecursive(nameFold + java.io.File.separator + normalizeName(folder.getName()), folder.getId(), map); } } } 搜索功能是: private static List<com.google.api.services.drive.model.File> search(Type type, String folderId) throws IOException, RefreshTokenException { String nextPageToken = "go"; List<File> driveFolders = new ArrayList<>(); com.google.api.services.drive.Drive.Files.List request = service.files() .list() .setQ("'" + folderId + "' in parents and mimeType" + (type == Type.FOLDER ? "=" : "!=") + "'application/vnd.google-apps.folder' and trashed = false") .setPageSize(100).setFields("nextPageToken, files(id, name)"); while (nextPageToken != null && nextPageToken.length() > 0) { try { FileList result = request.execute(); driveFolders.addAll(result.getFiles()); nextPageToken = result.getNextPageToken(); request.setPageToken(nextPageToken); return driveFolders; } catch (TokenResponseException tokenError) { if (tokenError.getDetails().getError().equalsIgnoreCase("invalid_grant")) { log.err("Token no more valid removing it Please retry"); java.io.File cred = new java.io.File("./tokens/StoredCredential"); if (cred.exists()) { cred.delete(); } throw new RefreshTokenException("Creds invalid will retry re allow for the token"); } log.err("Error while geting response with token for folder id : " + folderId, tokenError); nextPageToken = null; } catch (Exception e) { log.err("Error while reading folder id : " + folderId, e); nextPageToken = null; } } return new ArrayList<>(); } 我确信有一种方法可以通过很少的 api 调用(甚至可能是一个调用?)对每个文件(使用文件夹树路径)进行正确的映射,因为在我的版本中,我花了很多时间进行调用 service.files().list().setQ("'" + folderId+ "' in parents and mimeType" + (type == Type.FOLDER ? "=" : "!=") + "'application/vnd.google-apps.folder' and trashed = false").setPageSize(100).setFields("nextPageToken, files(id, name)"); 每个子文件夹至少一次......并且递归搜索所有内容需要很长时间。最后,映射比下载本身花费的时间更多...... 我搜索了文档,也在此处搜索,但没有找到任何内容来列出具有一个库的所有驱动器调用任何想法? 我想使用专用的 java API 来获取共享 GoogleDrive 中的所有文件及其相对路径,但调用次数尽可能少。 提前感谢您的时间和答复 我建议您使用高效的数据结构和逻辑来构建文件夹树并将文件映射到其路径,如下所示 private static void mapDriveContent(String driveId) throws IOException { // HashMap to store folder ID to path mapping HashMap<String, String> idToPath = new HashMap<>(); // HashMap to store files based on their paths HashMap<String, List<File>> pathToFile = new HashMap<>(); // Fetch all files and folders in the drive List<File> allFiles = fetchAllFiles(driveId); // Build folder path mapping and organize files for (File file : allFiles) { String parentId = (file.getParents() != null && !file.getParents().isEmpty()) ? file.getParents().get(0) : null; String path = buildPath(file, parentId, idToPath); if (file.getMimeType().equals("application/vnd.google-apps.folder")) { idToPath.put(file.getId(), path); } else { pathToFile.computeIfAbsent(path, k -> new ArrayList<>()).add(file); } } // Now, pathToFile contains the mapping of paths to files // Your logic to handle these files goes here } private static List<File> fetchAllFiles(String driveId) throws IOException { // Implement fetching all files and folders here // Make sure to handle pagination if necessary // ... } private static String buildPath(File file, String parentId, HashMap<String, String> idToPath) { // Build the file path based on its parent ID and the idToPath mapping // ... }


Struts 2 与 Apache Shiro 集成时如何显示结果页面

使用: struts2 2.5.10, 春天 4.x, struts2-spring-插件2.5.10, 希罗1.4.0, Shiro-Spring 1.4.0。 网络.xml: 使用: struts2 2.5.10, 春季 4.x, struts2-spring-插件2.5.10, 四郎1.4.0, shiro-spring 1.4.0. web.xml: <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" version="3.1"> <display-name>Archetype Created Web Application</display-name> <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:beans.xml</param-value> </context-param> <filter> <filter-name>shiroFilter</filter-name> <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class> <init-param> <param-name>targetFilterLifecycle</param-name> <param-value>true</param-value> </init-param> </filter> <filter> <filter-name>struts2</filter-name> <filter-class>org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter</filter-class> </filter> <!-- shiro filter mapping has to be first --> <filter-mapping> <filter-name>shiroFilter</filter-name> <url-pattern>/*</url-pattern> <dispatcher>REQUEST</dispatcher> <dispatcher>FORWARD</dispatcher> <dispatcher>INCLUDE</dispatcher> <dispatcher>ERROR</dispatcher> </filter-mapping> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> </web-app> beanx.xml: <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd "> <bean name="loginAction" class="example.shiro.action.LoginAction" > </bean> <bean id="shiroFilter" class="org.apache.shiro.spring.web.ShiroFilterFactoryBean"> <property name="securityManager" ref="securityManager" /> <property name="loginUrl" value="/login.jsp" /> <property name="filterChainDefinitions"> <value> /login.jsp = authc /logout = logout /* = authc </value> </property> </bean> <bean id="iniRealm" class="org.apache.shiro.realm.text.IniRealm"> <property name="resourcePath" value="classpath:shiro.ini" /> </bean> <bean id="securityManager" class="org.apache.shiro.web.mgt.DefaultWebSecurityManager"> <property name="realm" ref="iniRealm" /> </bean> <bean id="lifecycleBeanPostProcessor" class="org.apache.shiro.spring.LifecycleBeanPostProcessor"/> </beans> struts.xml: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd"> <struts> <constant name="struts.devMode" value="true" /> <package name="default" extends="struts-default"> <action name="list" class="loginAction" method="list"> <result name="success">/success.jsp</result> <result name="error">error.jsp</result> </action> </package> </struts> index.jsp: <body> <s:action name="list" /> </body> login.jsp 看起来像: <form name="loginform" action="" method="post"> <table align="left" border="0" cellspacing="0" cellpadding="3"> <tr> <td>Username:</td> <td><input type="text" name="username" maxlength="30"></td> </tr> <tr> <td>Password:</td> <td><input type="password" name="password" maxlength="30"></td> </tr> <tr> <td colspan="2" align="left"><input type="checkbox" name="rememberMe"><font size="2">Remember Me</font></td> </tr> <tr> <td colspan="2" align="right"><input type="submit" name="submit" value="Login"></td> </tr> </table> </form> LoginAction.list(): public String list() { Subject currentUser = SecurityUtils.getSubject(); if(currentUser.isAuthenticated()) {System.out.println("user : "+currentUser.getPrincipal()); System.out.println("You are authenticated!"); } else { System.out.println("Hey hacker, hands up!"); } return "success"; } shiro.ini: [users] root=123,admin guest=456,guest frank=789,roleA,roleB # role name=permission1,permission2,..,permissionN [roles] admin=* roleA=lightsaber:* roleB=winnebago:drive:eagle5 index.jsp、login.jsp、success.jsp放在webapp下 我想要的是:输入LoginAction.list()需要进行身份验证,如果登录成功,则运行LoginAction.list()并返回"success"然后显示定义为Struts操作结果的success.jsp。 现在登录成功后可以执行LoginAction.list(),但是success.jsp不显示,浏览器是空白页面。 为什么? 我找到了原因:我在index.jsp中使用了<s:action name="list" />,但是struts文档说如果我们想用<s:action>看到结果页面,那么我们必须将其属性executeResult设置为true,即就像<s:action name="list" executeResult="true"/>。 在我看来,这有点奇怪,这个属性默认应该是 true。 有一个示例,您应该如何使用 Shiro applicationContext.xml 进行配置: <property name="filterChainDefinitions"> <value> # some example chain definitions: /admin/** = authc, roles[admin] /** = authc # more URL-to-FilterChain definitions here </value> </property> 以 /admin/ 开头的 URL 通过角色 admin 进行保护,任何其他 URL 均不受保护。如果 Struts 操作和结果 JSP 不在受保护区域中,则会显示它们。


使用 libcurl 时出现“SSL CA 证书问题”错误

我使用--openssldir=< path to ssl >/ssl(链接到/etc/ssl)构建了openssl 1.1.1,并使用--with-ssl=< path to openssl >构建了curl 7.76.1。 编译了以下代码: #包括 我使用--openssldir=< path to ssl >/ssl(链接到/etc/ssl)构建了openssl 1.1.1,并使用--with-ssl=< path to openssl >构建了curl 7.76.1。 编译了以下代码: #include <iostream> #include <curl/curl.h> int main() { CURL *curl = curl_easy_init(); if (curl) { struct curl_slist *headers = NULL; headers = curl_slist_append(headers, "Accept: */*"); headers = curl_slist_append(headers, "Content-Type: application/json"); curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers); curl_easy_setopt(curl, CURLOPT_URL, "https://<address>"); curl_easy_setopt(curl, CURLOPT_POST, 1); curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "<some data>"); curl_easy_perform(curl); curl_slist_free_all(headers) } curl_easy_cleanup(curl); } 当我运行此代码时,出现错误: curl_easy_operation() failed : Problem with the SSL CA cert (path? access rights?) 我在 strace 中看到,它正在尝试打开“/etc/pki/tls/certs/ca-bundle.crt” 但在我的机器(Ubuntu 12 和 Ubuntu 14)中没有文件夹“/etc/pki”。 为什么curl使用“/etc/pki”而不是“/etc/ssl”?我怎样才能强制它使用“/etc/ssl”? 我尝试使用 --without-nss 构建curl,但没有成功。 编辑: 我的解决方案是添加以下代码: ifstream caBundleFile("/etc/pki/tls/certs/ca-bundle.crt"); if (caBundleFile.good()) { curl_easy_setopt(curl, CURLOPT_CAINFO, "/etc/pki/tls/certs/ca-bundle.crt"); caBundleFile.close(); } else { curl_easy_setopt(curl, CURLOPT_CAPATH, "/etc/ssl/certs"); } 有两种流行的存储根证书的格式。第一个适用于 RHEL/Centos 等,第二个适用于 Ubuntu 等发行版。 对于未来的读者,答案是设置curl CA路径 #include <iostream> #include <curl/curl.h> const std::string curlCertPath = "./keys/curl-ca-bundle.crt"; int main() { CURL *curl; CURLcode res; curl_global_init(CURL_GLOBAL_ALL); curl = curl_easy_init(); if (curl) { curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); curl_easy_setopt(curl, CURLOPT_CAINFO, curlCertPath.c_str()); res = curl_easy_perform(curl); if (res == CURLE_OK) { std::cout << "Curl worked" << std::endl; } else { std::cout << "Error: curl failed: " << curl_easy_strerror(res) << std::endl; } curl_easy_cleanup(curl); } curl_global_cleanup(); return 0; }


在这个curl api中将不记名授权令牌放在哪里

我正在使用 imageqrcode (https://imageqrcode.com/apidocumentation) 的新 api 功能来动态生成图像 QR 码,使用 php: 我正在使用 imageqrcode (https://imageqrcode.com/apidocumentation) 的新 api 功能来动态生成图像 QR 码,使用 php: <?php $api_key = 'xxxxxxxxxx'; //secret // instantiate data values $data = array( 'apikey' => $api_key, 'qrtype' => 'v1', 'color' => '000000', 'text' => 'https://wikipedia.com', ); // connect to api $url = 'https://app.imageqrcode.com/api/create/url'; $ch = curl_init($url); // Attach image file $imageFilePath = 'test1.jpg'; $imageFile = new CURLFile($imageFilePath, 'image/jpeg', 'file'); $data['file'] = $imageFile; curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); curl_close($ch); // Handle the response $result = json_decode($response, true); if ($result && isset($result['downloadURL'])) { // Successful request $download_url = $result['downloadURL']; echo "Download URL: $download_url"; } else { // Handle errors echo "Error: " . print_r($result, true); } ?> 在文档中显示有变量“serialkey”: 图片二维码API文档 API文档 生效日期:2023年11月15日 图像二维码 API 是一项接受 HTTPS 请求以生成图像或 gif 二维码的服务,主要由开发人员使用。 图像二维码 - URL JSON 请求(POST):https://app.imageqrcode.com/api/create/url apikey //你的apikey 序列号//你的序列号 qrtype //字符串,最少 2 个字符,最多 2 个字符v1 或 v2,v1 适用于 QR 类型 1,v2 适用于类型 2 color //数字,最小 6 位,最大 6 位,例如000000 为黑色 text //url,最少 15 个字符,最多 80 个字符https://yourwebsite.com file //图像文件 (jpg/jpeg/png),最大 1 MB 文件大小 现在没有信息将该序列密钥作为标准承载授权令牌放在哪里???如果没有此信息,我无法连接到 api 我尝试在没有不记名令牌的情况下连接它,因为我认为它可以匿名连接到 api,但也不起作用,我现在很困惑,因为我仍在学习 PHP 和 Laravel 看起来 serialkey 不是不记名令牌,而是一个应该与其他参数(如 apikey、qrtype、color、text 和 )一起包含在 POST 数据中的参数file。您可以在 PHP 代码的 serialkey 数组中包含 $data。 $data = array( 'apikey' => $api_key, 'serialkey' => 'your_serial_key', // Add this line 'qrtype' => 'v1', 'color' => '000000', 'text' => 'https://wikipedia.com', );


© www.soinside.com 2019 - 2024. All rights reserved.