location-based-service 相关问题


根据单一条件改变几列

df <- data.frame(x=1:10) Can I mutate several columns based on a single condition? For example, I can do this: df %>% 变异(y = if_else(x>3,"Y","N"), z = if_else(x>...


如何停止渲染 app.js 中的组件

}> } /> <SideBar /> <Routes> <Route path='/' element={<Body />}> <Route path='/' element={<Home />} /> <Route path='setting' element={<Setting />} /> </Route> <Route path='/service' element={<ServiceLayout />}> <Route path='/service' element={<Service />} /> </Route> </Routes> <Article /> </div> 我不想在服务组件中渲染文章组件。我怎么做?请帮助我。 Article组件无条件在路由内容下渲染。 <div className='App'> <SideBar /> <Routes> <Route element={<Body />}> <Route path='/' element={<Home />} /> <Route path='setting' element={<Setting />} /> </Route> <Route path='/service' element={<ServiceLayout />}> <Route index element={<Service />} /> </Route> </Routes> <Article /> // <-- always rendered! </div> 简单的解决方案就是从 JSX 中删除 Article: <div className='App'> <SideBar /> <Routes> <Route element={<Body />}> <Route path='/' element={<Home />} /> <Route path='setting' element={<Setting />} /> </Route> <Route path='/service' element={<ServiceLayout />}> <Route index element={<Service />} /> </Route> </Routes> {/* <Article /> removed */} </div> 但这可能不是您真正想要的。另一种选择是有条件地在路线上渲染它。 示例: <div className='App'> <SideBar /> <Routes> <Route element={<Body />}> <Route path='/' element={<Home />} /> <Route path='setting' element={<Setting />} /> </Route> <Route path='service' element={<ServiceLayout />}> <Route index element={<Service />} /> </Route> </Routes> <Route path='article' element={<Article /> } /> // <-- only on "/article" path </div>


访问Service中的请求范围Bean

我有一个常规bean,它是(a)@Scope(“request”)或(b)通过过滤器/拦截器放置在HttpServletRequest中。 如何在@Service 中访问这个bean,这是一种应用程序......


微服务中如何处理关系?

假设我有一个名为 User-Service 的微服务,它只处理用户相关的数据,它存储在 PG 中,同时我有一个 Car-Service,它只处理与汽车相关的数据,我...


a9g 模块中的“AT+location=2”即可获取纬度和经度。我不能

我正在尝试使用 at+location=2 从板 a9g 获取坐标 小图书馆有时工作有时不工作。 获取字符串坐标的函数是: 字符串 sendData(字符串命令, const int ti...


@Service 不在实现类中工作

界面: 公共接口注册服务 实现类: @服务 公共类 RegistrationServiceImpl 实现 RegistrationService{ @Autowired 注册服务


任何人都可以帮助我避免在应用程序上使用模拟位置时被检测到吗,我已经反编译并粘贴了其中的代码,smali 文件

.第 1854 行 invoke-virtual {p1}, Landroid/location/Location;->isFromMockProvider()Z 移动结果 p1 转到:goto_6 .1856号线 :条件_d iget-object p1、p0、Lcom/bel/HYS/FileexplorerActivity$


Get-AzVMImage 不输出 PSVirtualMachineImageDetail

我试图从天蓝色的虚拟机映像中获取详细信息,但该信息似乎不存在。 $location =“瑞典中央” $publisher = "MicrosoftSQLServer" #G...


不安全无数据块在chrome浏览器中自动化执行

我在selenium 4.16.0,chrome-120.0.6099.217中使用了上面的代码 从 selenium.webdriver.edge.service 导入服务 service_obj = 服务() 驱动程序 = webdriver.Chrome(service=service_obj) 司机....


如何使用 virt-install 在 aarch64 虚拟机上配置显示

我正在运行这个命令: virt-install --virt-type kvm --name oracle --ram 4096 --location=/ssd/OracleLinux-R9-U3-aarch64-dvd.iso --磁盘路径=/ssd/OracleLinux-R9-U3-aarch64 -cloud.qcow2 --network=de...


Flutter 中可以使用什么包来代替 open_file?

我在 Flutter 中有一个项目,我正在使用 open_file 包。我已将 Flutter 生成的 Android apk 上传到 AppSweep,它返回以下问题:Insecure file location is retr...


无法加载config.js

我将 Jitsi Flutter 插件与 8x8 的 Jitsi-as-a-Service 产品结合使用,将视频通话集成到我的移动应用程序中。 加入会议后,通话立即结束,Jitsi c...


Nuxt 3 项目无法找到 PWA 图标

开发工具错误 我目前正在尝试在我的 nuxt 3 项目中实现 PWA 功能,但我不断遇到这个问题:[Vue Router warn]: No match found for location with path "/icon_512x512...


Appwrite JWT 身份验证

我正在尝试通过经过身份验证的用户(JWT)执行Appwrite功能。我做什么: 我创建电子邮件会话 curl --location 'http://localhost/v1/account/sessions/email' \ --header '内容类型:应用...


3 月 31 日之后 Azure 应用服务备份是否可用?

关于微软针对 azure 应用程序服务的声明,摘自此处 https://learn.microsoft.com/en-us/azure/app-service/manage-disaster-recovery “从 2025 年 3 月 31 日开始,Azure ...


Elastic APM 服务器在 Docker 中不可用

我正在尝试运行 apm-server 使用 apm-agent 从基于 java 的应用程序收集并发送给 Elasticsearch。 这是我的撰写文件: 服务: 订单服务: 图片:apm-java/order-service:1.0.0 ...


Azure App Service Plan 也是安全边界吗?

我知道Azure应用程序服务计划主要是一种为一组Azure应用程序服务配置资源(vCPU、RAM等)的方法。但这也是安全边界吗? 换句话说,如果我主持两个


将字符串提取到变量中是否可以节省内存或性能,或者仅用于提高代码可读性?

假设我有这个 ItemWrapper 类,用于生成许多项目。在它的构造函数内部,我使用“Location Item”字符串,我知道我只会在这里使用它。 类 ItemWra...


如何在 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 标签或不同顺序的标签不会扰乱你的转换。


如何从当前打开的 HTML 网站中的元素获取数据?

我发现自己需要深入研究开放网站的 HTML 代码,并从 标签获取一些数据,特别是其中的背景图像元素的值。这个元素改变... 我发现自己需要深入研究开放网站的 HTML 代码,并从 <div> 标签获取一些数据,特别是其中的 background-image 元素的值。该元素会根据页面上执行的操作而发生变化。现在我需要找出如何让我的代码从 Firefox 中打开的选项卡返回该特定元素的值。最简单的方法是什么? 我看了美丽汤,但我不知道还需要搭配什么。据我所知,它对于解析 HTML 数据很有用,但对于首先获取该数据却没有用。 您可以使用 requests 来获取页面的 HTML 内容,如下所示: import requests from bs4 import BeautifulSoup def scrape_website(url): # Send an HTTP request to the URL response = requests.get(url) # Check if the request was successful (status code 200) if response.status_code == 200: # Parse the HTML content of the page soup = BeautifulSoup(response.content, 'html.parser') # Extract data based on HTML structure (replace with your own logic) divs = soup.find_all('div') for div in divs: print(div.text) else: print(f"Failed to retrieve the page. Status code: {response.status_code}") 这里我们向站点发送一个 HTTP 请求,如果响应是 200(等于 ok ),我们将响应中的 HTML 数据发送到变量并使用 Beatiful Soup 解析它。您需要将解析代码更改为最适合您的代码,但此时您可以询问 Chat-GPT。


通过更少的 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 // ... }


为什么 Odoo 17 没有在 <notebook> 中为我的字段渲染标签?

我正在运行有关 Odoo 17 开发的教程,并为第 7 章中的练习创建了以下代码: 我正在运行有关 Odoo 17 开发的教程,并且我为第 7 章中的练习创建了此代码: <record id="estate_view_form" model="ir.ui.view"> <field name="name">estate.property.form</field> <field name="model">estate.property</field> <field name="arch" type="xml"> <form string="Estate Property" create="True"> <sheet> <group string="Info"> <field name="name" /> <field name="description" /> </group> <group string="Location"> <field name="postcode" /> </group> <notebook> <page string="Specs"> <field name="facades" /> <field name="garage" /> </page> </notebook> </sheet> </form> </field> </record> 它可以工作,但 <notebook> 中字段的标签未呈现。我尝试添加 string 属性,但这不起作用。 <notebook> 上的 文档没有提及任何有关此行为的信息。 IIRC 自从我使用的每个版本(6.1+)以来,你必须在 group 周围有一个 field 才能自动获取标签。


修改现有的.htaccess,使其忽略子域

我有以下 .htaccess 文件,虽然我知道它远非最佳(并且可能有点令人畏惧) - 它只是有效。 # 防止公众查看 .htaccess 文件 我有以下 .htaccess 文件,虽然我知道它远非最佳(而且可能有点令人难受) - 它只是有效。 # Prevents public viewing of .htaccess file <Files .htaccess> order allow,deny deny from all </Files> # Custom 404 page ErrorDocument 404 https://www.domain.com/404/ # Turn on rewriting and set rewriting base RewriteEngine On RewriteBase / # Force WWW RewriteCond %{HTTP_HOST} !^$ RewriteCond %{HTTP_HOST} ^([^.]+)\.([a-z]{2,4})$ [NC] RewriteCond %{HTTPS}s ^on(s)| RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=302,L] # Force WWW and HTTPS RewriteCond %{HTTP_HOST} !^www\. [NC,OR] RewriteCond %{HTTPS} off RewriteRule ^ https://www.domain.com%{REQUEST_URI} [R=301,L] # Remove .php extension RewriteRule ^(properties)/(all|location1|location2|location3)/(all|1|2|3|4|5|6|7|8|9)/(asc|desc) $1.php?location=$2&bedrooms=$3&sort-by=$4 RewriteRule ^(properties)/(all|location1|location2|location3)/(all|1|2|3|4|5|6|7|8|9) $1.php?location=$2&bedrooms=$3 RewriteRule ^(properties)/(all|location1|location2|location3) $1.php?location=$2 RewriteRule ^(view-property)/(.*)/(print-view) $1.php?id=$2&print=true RewriteRule ^(view-property)/(.*)/ $1.php?id=$2 RewriteRule ^(.*)/$ $1.php 我们的新网站现已准备好推送到我们新创建的临时环境中进行测试。在本例中,它会是 staging.domain.com,但我们在实际访问此暂存 URL 时遇到问题。 编辑 - 只是为了澄清,问题是访问 staging.domain.com 重定向到 https://www.domain.com。 我们认为问题是由我们上面的重写规则引起的。我研究了一些可能的解决方案,包括向现有重写规则添加附加条件,例如: RewriteCond %{HTTP_HOST} !^staging\.domain\.com 或添加新的条件/规则,例如: RewriteCond %{HTTP_HOST} ^staging\.domain\.com [NC] RewriteRule ^(.*) - [L] 但不幸的是这些都不起作用。使用 .htaccess 文件确实不是我的强项,所以如果有人可以提供任何帮助,那就太好了。 附注新网站由 Laravel 5.3 提供支持,因此当我们上线时,我将摆脱重写规则(位于底部的规则)的可怕尝试! 您的顶级规则必须更改为此以删除目标 URL 中的硬编码域名: # Turn on rewriting and set rewriting base RewriteEngine On RewriteBase / # Force WWW and HTTPS RewriteCond %{HTTP_HOST} !^www\. [NC,OR] RewriteCond %{HTTPS} off RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC] RewriteRule ^ https://www.%1%{REQUEST_URI} [R=301,L,NE] # Remove .php extension and rest of the rewrite rules Crypto.com 登录问题 已经是 crypto.com 登录用户?继续作为 crypto.com 登录问题用户。或者。电子邮件。密码。登录 忘记密码?没有帐户?立即注册。注册 Crypto.com NFT 帐户 · 连接您经过验证的 crypto.com 登录问题 · 提交申请成为创建者 Trezor suite 应用程序 移动版 Trezor Suite Lite 是一款免费应用程序,可让您同步和跟踪所有比特币和加密货币您手机上的帐户。适用于 Trezor 硬件钱包的新桌面和浏览器应用程序。 Trezor Suite 在可用性、安全性和隐私这三个关键支柱上带来了重大改进。


在 Rails 5 中单击浏览器上的后退按钮时,带有 Select2 的表单会重复

_header.html.erb(用于表单部分) <%= form_for home_path, class: 'home', role: 'search', method: :get do |f| %> _header.html.erb(用于表单部分) <%= form_for home_path, class: 'home', role: 'search', method: :get do |f| %> <div class="form-group" style="display:inline;"> <div class="input-group input-group-md"> <%= text_field_tag :q, params[:q], placeholder: ... ,class: 'form-control hideOverflow', type: "search" %> <%= select_tag "category", options_from_collection_for_select(...),include_blank: true, class: 'form-control hideOverflow', type: "search" %> <%if logged_in? %> <%= select_tag "location", options_for_select([...], ...),class: 'form-control hideOverflow', type: "search" %> <% else %> <%= select_tag "location", options_for_select([...], ...),class: 'form-control hideOverflow', include_blank: true, type: "search" %> <% end %> <span class="input-group-addon"><%= submit_tag "Search", class: "btn-transparent"%></span> </div> </div> <% end %> JS代码 <script> $( document ).on('turbolinks:load', function() { $('select#category').select2({ width: '60%', dropdownAutoWidth : true, placeholder: "Choose a category", maximumSelectionLength: 3 }); $('select#location').select2({ width: '40%', dropdownAutoWidth : true, minimumResultsForSearch: Infinity }); }); </script> 故障或渲染问题(单击链接查看图像) 有人可以帮我解决为什么吗?另外,我的搜索表单位于标题部分文件的导航栏中。 如果我去掉脚本中的 $(...).select ,一切都会正常...我认为 select.js 有问题 在此回复: https://stackoverflow.com/a/41915129/5758027 我在自己的代码中使用了这个解决方案: $(document).on('turbolinks:before-cache', function() { // this approach corrects the select 2 to be duplicated when clicking the back button. $('.select-select2').select2('destroy'); $('.select-search-select2').select2('destroy'); } ); 和观察者: $(document).ready( ready ); //... once document ready $(document).ajaxComplete( ready ); //... once ajax is complete $(document).on('turbolinks:load', ready ); //... once a link is clicked function ready() { $(".select-search-select2").select2({ theme: "bootstrap", language: 'es', allowClear: true }); $(".select-select2").select2({ theme: "bootstrap", language: 'es', minimumResultsForSearch: Infinity, allowClear: true }); }; 总是清除缓存不是会让使用 Turbolink 变得毫无意义吗? 不如这样? $(document).on('turbolinks:before-cache', function(e) { return $('.form-control.select2').each(function() { return $(this).select2('destroy'); }); }); 我无法解决这个渲染问题(仍在等待正确的答案!),但如果有人像我一样遇到类似的问题,请尝试跳出框框思考。这是我的技巧:我在应用程序中添加了一个后退按钮。 获取完整的url路径 # get the previous url def save_previous_page session[:return_to] = request.fullpath end 仅当页面不是主页或搜索页面时才显示后退按钮 <% if session[:return_to] != request.fullpath%> <%= link_to session.delete(:return_to) || request.fullpath, class: 'back-button' do%> <i class="fa fa-arrow-circle-left" aria-hidden="true"></i> <%end%> <% end %> 同时,我仍在等待并尝试解决渲染问题... 解决了问题 只需将此代码添加到您的 .js 文件中 Turbolinks.clearCache(); 这很可能是一些资源不一致,您应该检查您的 app\views\layouts 文件夹中是否有重复声明 wither jQuery、jQuery UJS 或 Turbolinks 的文件。检查页面的所有 <script> 标签,以及是否在 layout 文件夹和内部视图中声明相同的脚本。如果情况并非如此,请检查是否有 render、yield 或 build 呼叫 简单的解决方案,不要在您不希望它运行的东西上运行 select2 构建器。 $("select#category:not(.select2-container):not(.select2-hidden-accessible)").select2(); Rails 7 更新 这里的很多东西在 Rails 7 中都不起作用,尤其是 turbolinks:before-cache 事件。您正在寻找的新事件是 turbo:before-cache 和 turbo:load,所以它看起来像这样: $(document).on("turbo:before-cache", function() { $("#select_id").select2('destroy'); }); $(document).on('turbo:load', function() { $('#select_id').select2(); });


如何在C#中正确导入不同项目的Proto文件?

我的解决方案中有 2 个项目 /Common/Common.csproj /数据/Data.csproj 我的 Data.csproj 中有一个 Proto 文件: 我的解决方案中有 2 个项目 /通用/Common.csproj /数据/Data.csproj 我的 Data.csproj 中有一个 Proto 文件: <Protobuf Include=".\Protos\UserService.proto" GrpcServices="Server" /> 看起来像这样: service UserService { rpc AddUser (UserRequest) returns (SimpleResponse); } .... 现在应该从 Common 导入 SimpleReponse,所以我在这个项目中的路径 /Common/Protos/common.proto 中创建了一个 common.proto,我想导入它: 导入“common.proto”; 服务用户服务{ rpc AddUser(UserRequest) 返回(SimpleResponse); } .... 然后 Rider 显示 SimpleResponse 仍为红色,以及 common.proto 导入。当我快捷键 Space + .它会向我显示我所做的“添加到原始导入”。 因此,在全局设置中,路径现在已正确设置 - 原型和响应不再是红色,我可以按 F12 来查看它们。当我现在尝试构建时,我仍然收到错误: 我尝试在csproj中添加路径 <Protobuf Include="..\Common\Protos\common.proto" Link="..\Common\Protos\common.proto" /> 但仍然是同样的错误。 有什么想法吗? 从不同项目导入原始文件非常棘手,我发现这个解决方案非常费力。所以我想与社区分享 我正在使用微服务架构,我希望我的消息 ProtoFiles 应该在 SharedProto 项目中并在不同的项目中使用它们 假设我在 SharedProto 中有消息 Proto 文件 SharedProto --Protos ----company_dto.proto ----branch_dto.proto ---- ... company_dto.proto的内容 syntax = "proto3"; option csharp_namespace = "SharedProto.Protos"; package sharedproto.protos; // *** DTO message CompanyDto { int32 Id = 1; string Code = 2; string Name = 3; string Logo = 4; string Website = 5; } SharedProto.csproj 的内容 .... <ItemGroup> <Protobuf Include="Protos\company_dto.proto" GrpcServices="None"> <Protobuf Include="Protos\branch_dto.proto" GrpcServices="None"> </ItemGroup> .... 我拥有服务原型的项目组织 Organization ... --Protos ----company_rpc.proto ----branch_rpc.proto ... 我想将 comapany_dto.proto(属于 SharedProto 项目的一部分)导入到 comapany_rpc.proto(属于 Organization 项目的一部分)。让我们看看 .csproj 文件,因为所有的技巧都在这里: 组织.csproj的内容 <ItemGroup> <ProjectReference Include="..\SharedProto\SharedProto.csproj"> <GlobalPropertiesToRemove></GlobalPropertiesToRemove> </ProjectReference> </ItemGroup> <ItemGroup> <!-- DTOs --> <Protobuf Include="..\SharedProto\Protos\company_dto.proto" ProtoRoot=".." GrpcServices="None" Link="Protos\company_dto.proto" /> <Protobuf Include="Protos\company_rpc.proto" AdditionalImportDirs="../SharedProto" GrpcServices="Server" /> </ItemGroup> 如果您看到上面的 Organzation.csproj 文件,那么您需要了解一些非常重要的要点,以避免 file not found error 从其他项目导入 proto 文件。 ProtoRoot=".." 和 Link="Protos\company_dto.proto" 之后,将此 AdditionalImportDirs="../SharedProto" 添加到要导入文件的 <Protobuf Include=.... 上。但是,在这些设置之后,您可以在其他项目中导入 SharedProto 文件,在我的例子中它是组织项目。看看吧 company_rpc.proto内容 syntax = "proto3"; import "google/protobuf/empty.proto"; import "Protos/company_dto.proto"; package organization.companyrpc; // *** Rpc-Service service CompanyRpcService { // Retrieve All rpc GetAllCompanies (google.protobuf.Empty) returns (GetCompanyListResponse){ } .... } // Response: Retrieve All message GetCompanyListResponse { repeated sharedproto.protos.CompanyDto DtoRows = 1; string Message = 2; } 如果您看到我的company_rpc.proto文件,您就会了解我如何导入它(import "Protos/company_dto.proto";)以及我如何使用它(sharedproto.protos.CompanyDto DtoRows) 记住这个sharedproto.protos来自company_dto.proto文件中的包名称 上述设置适用于我的 .net core grpc 2.60.0 和 .net core 8


使用 IndexedPointInAreaLocator 和 STRTree(JTS 拓扑套件)无法实现多边形中的点性能

私人列表findZonesForShipPosition(点点){ List zoneDefinitionCacheHits = new ArrayList<>(); strTree.query(point.getEnvelopeIn... private List<ZoneDefinitionCacheMemory> findZonesForShipPosition(Point point) { List<Object> zoneDefinitionCacheHits = new ArrayList<>(); strTree.query(point.getEnvelopeInternal(), zoneDefinitionCacheHits::add); return zoneDefinitionCacheHits.stream() .filter(ZoneDefinitionCacheMemory.class::isInstance) .map(ZoneDefinitionCacheMemory.class::cast) .filter(zoneDefinition -> isPointInsideGeometry(point, zoneDefinition.getGeometry())) .toList(); } private boolean isPointInsideGeometry(Point point, Geometry geometry) { PointOnGeometryLocator pointOnGeometryLocator = new IndexedPointInAreaLocator(geometry); int location = pointOnGeometryLocator.locate(point.getCoordinate()); boolean isInside = location == Location.INTERIOR; return isInside; } 我使用上面的代码来搜索多边形中的点,在查询之前将所有多边形和多边形插入到 strTree 中,并且我还使用 IndexedPointInAreaLocator 在 STR Tree 的顶部添加一个附加过滤器来验证是否给定点是否确实位于几何中。 此外,我的多边形非常大,这意味着某些多边形中有近 160 万个点。 因此,通过此实现,我面临着性能问题,这种方法至少需要 100 毫秒才能完成,这对于我的用例来说是不期望的。 这里可能出现什么问题?或任何以某种方式加快速度的建议。 我的用例:我将获得很多点来检测它们是否位于给定几何形状(多边形和多多边形)的内部或外部 我尝试使用 Polygon.contains(point) 谓词,但它比 IndexedPointInAreaLocator 方法花费更多时间。 如果你的多边形很大(从某种意义上说它们覆盖了很大的区域)或者形状很奇怪。然后,细分它们可能会提高索引性能,请记住索引首先在多边形的边界框上工作,以节省在多边形测试中进行昂贵的点。如果一个点落入许多边界框但只有一个多边形,则索引不会有太大帮助。 Paul Ramsey 的这篇博客文章在 PostGIS 上下文中讨论了这一点,但这里的底层实现是相同的。这个answer将帮助您划分多边形(因为我认为JTS没有细分方法)。 您还可以从 JTS 代码周围使用 GeoTools 中受益,因为这将允许您切换到使用具有内置索引的 PostGIS 或 GeoPackage 数据库,或更简单的 在内存存储中建立索引。


如何解决数字格式异常?

index.html 输入第一个数字: 输入第二个数字... index.html <!DOCTYPE html> <html> <body> <form action="add"> Enter 1st number:<input type="text" name="num1"><br> Enter 2st number:<input type="text" name="num1"><br> <input type="submit"> </form> </body> </html> AddServlet.java 这是 servlet 代码。 package com.adithya; import java.io.IOException; import java.io.PrintWriter; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; public class AddServlet extends HttpServlet { public void service(HttpServletRequest req,HttpServletResponse res) throws IOException { int i=Integer.parseInt(req.getParameter("num1")); int j=Integer.parseInt(req.getParameter("num2")); int k=i+j; PrintWriter out=res.getWriter(); out.println("result is"+k); } } 我正在尝试获取结果,但它显示了如下所示的异常。我无法理解例外情况。 ** 例外** 这显示了这样的异常。我无法识别问题所在。 java.lang.NumberFormatException: Cannot parse null string java.base/java.lang.Integer.parseInt(Integer.java:630) java.base/java.lang.Integer.parseInt(Integer.java:786) com.adithya.AddServlet.service(AddServlet.java:19) javax.servlet.http.HttpServlet.service(HttpServlet.java:623) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51) 我不明白这是什么错误。我试图从 2 天开始解决这个问题。请任何人帮助我解决这个问题。但它不起作用。 您有 2 个相同的名字 num1,并且您正在尝试呼叫不在场的 num2。 Enter 2st number:<input type="text" name="num1"><br> 关于: Enter 2st number:<input type="text" name="num2"><br>


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 版本兼容性。


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 文档。


Tomcat SOLR 多核设置

我花了整个上午尝试在 Apache Tomcat 服务器下运行的 SOLR 安装上设置多个核心,但没有成功。我的 solr.xml 如下所示: 我花了整个上午尝试在 Apache Tomcat 服务器下运行的 SOLR 安装上设置多个核心,但没有成功。我的 solr.xml 看起来像这样: <solr persistent="false" sharedLib="lib"> <cores adminPath="/admin/cores"> <core name="core0" instanceDir="/multicore/core0"> <property name="dataDir" value="/multicore/core0/data" /> </core> <core name="core1" instanceDir="/multicore/core1"> <property name="dataDir" value="/multicore/core1/data" /> </core> </cores> </solr> 正确的目录结构是什么?我需要更改 solrconfig.xml 中的某些内容吗? 检查您的instanceDir值是否相对于-Dsolr.solr.home。如果 -Dsolr.solr.home 是“多核”,那么您的 instanceDir 应该只是“core0”。 如果将数据文件夹放在instanceDir中,则不必指定其路径: <?xml version='1.0' encoding='UTF-8'?> <solr persistent="true"> <cores adminPath="/admin/cores"> <core name="core0" instanceDir="core0" /> <core name="core1" instanceDir="core1" /> </cores> </solr> 您不必在 solrconfig.xml 中设置任何内容。但如果您需要独立于核心位置配置处理程序,则可以使用变量 ${solr.core.instanceDir}。 更新 要使用 Tomcat 设置 solr.solr.home 变量,请在启动 Tomcat 之前使用 JAVA_OPTS 环境变量: JAVA_OPTS="-Dsolr.solr.home=multicore" export JAVA_OPTS tomcat/bin/catalina.sh start 确保相对于工作目录正确设置“多核”。例如,如果 solr.solr.home='multicore',则必须从“multicore”所在的目录启动 Tomcat。 这有点晚了,但我刚刚发布了一篇博客文章,其中包含 Tomcat 上多核 SOLR 实例的说明,内容如下: 下载并安装32位/64位Windows服务 Tomcat 安装程序 在服务器上安装 Tomcat(无 这里有特别说明——只需运行安装并安装到任何地方 你希望) 通过访问 http://localhost:8080 验证 Tomcat 的安装 编辑 Tomcat conf/server.xml 并将 URIEncoding="UTF-8" 添加到 元素如下所示 下载 SOLR 来自此处找到的镜像之一(下载了 apache-solr-1.4.1.zip 包)并解压包 创建SOLR目录 将由(在我的例子中我使用 e:\inetpub\solr)托管 复制 将 example\solr 目录的内容添加到您的 SOLR 主机目录(在我的例子中为 e:\inetpub\solr) 创建 您的每个核心的 SOLR 主机目录下的目录 希望创建(我为每个我想要的核心创建了十几个文件夹 在 e:\inetpub\solr 目录中创建。目录 包括 en-US、en-CA、en-GB 等) 复制 solr.xml 文件来自 example\multicore 目录并将其粘贴到您的 SOLR 主机目录(在我的示例中为 e:\inetpub\solr) 编辑 solr.xml 文件包含每个的信息 您创建的核心的数量(如果您在主机下创建了一个文件夹) 名为 en-US 的核心,然后在 solr.xml 文件中的 元素: ) 停止 Tomcat 服务 复制 *solr*.war 文件 解压后的SOLR包中的dist目录 到您的 Tomcat webapps 文件夹 重命名 *solr*.war 文件转换为 solr.war 在 Windows 任务栏右侧的通知区域中,右键单击 Apache Tomcat 7 图标并选择 配置 单击Java 选项卡并将以下内容添加到 Java Options 文本中 框:-Dsolr.solr.home=e:\inetpub\solr(更改 e:\inetpub\solr 到托管 SOLR 的任何位置) 单击 对话框中OK,然后启动Tomcat service 打开 conf\solrconfig.xml 文件 在您创建的每个核心下并更改 dataDir 元素指向特定的 目录。如果此步骤未完成,您的所有核心都会 对他们的数据使用相同的数据存储。 停止并 重新启动 Tomcat 服务 测试您的核心是否正在运行 通过从网络浏览器运行查询http://localhost:8080/solr/en-US/select?q=*:*(替换 “en-US”与您为核心之一命名的任何内容)


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