从Eclipse WTP发布到服务器时如何排除Maven资源?(How do I exclude Maven resources when publishing from Eclipse WTP to a server?)
在部署或发布到服务器时,如何使WTP在src / main / resources文件夹中排除Maven资源? 例如,我创建了一些名为src / main / resources / qa和src / main / resources / prod的文件夹,在那里我有属性文件。 我想将它们用于部署,但我不希望它们出现在WAR文件中。
通过向我的pom.xml添加资源节,我可以从Maven构建中排除这些文件夹(例如,当我运行
mvn package
),它们不会显示在我的WAR文件工件中。但是,当我使用WTP的“Debug As ..”方法让Eclipse管理并连接到我的本地Tomcat服务器时,我可以看到WTP正在发布所有资源,包括我在本地Tomcat服务器中的排除文件夹。 我已经看过wtpwebapp文件夹,即WTP正在使用的部署目标,当我从Eclipse服务器定义中删除了我的WAR工件时,它就消失了。 然后,当我将项目添加回服务器时,排除的资源会找回自己的方式。
我已尝试在相应的源库上为我的项目的Java Build路径中显式排除带有“** / qa /”和“** / prod /”条目的文件夹,事实上,使用
mvn eclipse:clean eclipse:eclipse -Dwtpversion=2.0
重新创建Eclipse项目mvn eclipse:clean eclipse:eclipse -Dwtpversion=2.0
将自动为我添加构建路径排除项。 当WTP发布时,他们似乎并没有被尊重。How do I make WTP exclude Maven resources in the src/main/resources folder, when it deploys or publishes to a server? For example, I created a few folders named src/main/resources/qa and src/main/resources/prod, and in there I have properties files. I want to use them for deployment, but I don't want them in the WAR file artifact.
By adding a resources stanza to my pom.xml, I can exclude those folders from Maven builds (e.g. when I run
mvn package
), and they won't show up in my WAR file artifact.But, when I use the "Debug As.." approach with WTP to let Eclipse manage and attach to my local Tomcat server, I can see that WTP is publishing all the resources including my excluded folders in the local Tomcat server. I have watched the wtpwebapp folder, that is the deployment target WTP is using, disappear when I have removed my WAR artifact from the Eclipse server definition. Then, the excluded resources find their way back when I add the project back to the server.
I have tried explicitly excluding the folders with "**/qa/" and "**/prod/" entries in the Java Build path for my project on the appropriate source libraries, and in fact, recreating the Eclipse project using
mvn eclipse:clean eclipse:eclipse -Dwtpversion=2.0
will add the build path exclusions for me automatically. They just don't seem to be honored when WTP publishes.
原文:https://stackoverflow.com/questions/26854052
最满意答案
问题是,您对所有选择使用相同的范围变量。 您可以将所选选项存储在数组中,如下所示:
function TestCtrl($scope) { $scope.items = [ { id: 1, class: 1 }, { id: 2, class: 2 }, { id: 3, class: 1 }, ]; $scope.classes = [ { name: "class 1", id: 1}, { name: "class 2", id: 2}, { name: "class 3", id: 3} ]; };
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script> <div ng-app> <div ng-controller="TestCtrl"> <div ng-repeat="currentItem in items"> <select ng-model="selectedClass[$index]" ng-init="selectedClass[$index]=(classes|filter:{id: currentItem.class})[0]" ng-options="class.name for class in classes track by class.id" > </select> selected class: {{selectedClass[$index]}} </div> </div> </div>
在这个例子中,我使用变量$ index,它由ng-repeat指令设置。 顾名思义它包含了repeat循环的当前索引。
UPDATE
我更新了代码片段,因此它为每个选择输入设置了默认值。
现在,不同的项目包含一个具有相应类的id的字段。 我用
ng-init
初始化选择输入。 使用此指令,我设置了selectedClass[$index]
,它是当前项的选定值。 因为我们只将class-id作为项的属性,所以我使用过滤器来查找具有id的相应类对象(classes|filter:{id: currentItem.class})[0]
要摆脱过滤器,您只需将每个项目的类设置为完整的类对象而不是id。
The problem is, that you are using the same scope variable for all selections. You could store the selected options in an array too like this:
function TestCtrl($scope) { $scope.items = [ { id: 1, class: 1 }, { id: 2, class: 2 }, { id: 3, class: 1 }, ]; $scope.classes = [ { name: "class 1", id: 1}, { name: "class 2", id: 2}, { name: "class 3", id: 3} ]; };
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script> <div ng-app> <div ng-controller="TestCtrl"> <div ng-repeat="currentItem in items"> <select ng-model="selectedClass[$index]" ng-init="selectedClass[$index]=(classes|filter:{id: currentItem.class})[0]" ng-options="class.name for class in classes track by class.id" > </select> selected class: {{selectedClass[$index]}} </div> </div> </div>
In this example I take use of the variable $index, which is set by the ng-repeat directive. As the name suggests it contains the current index of the repeat-loop.
UPDATE
I updated the code-snippet so it sets the default value for each select input.
The different items now contain a field with the id of the corresponding class. I initialize the select input with
ng-init
. With this directive I setselectedClass[$index]
which is the selected value for the current item. As we only have the class-id as a property of the items I use a filter to find the corresponding class object with the id(classes|filter:{id: currentItem.class})[0]
To get rid of the filter you could just set the class of each item to the full class-object instead of the id.
相关问答
更多-
我为这个要求做了一个小的解决方法,虽然这不是一个直接的答案,我相信这会对你有所帮助...... 将其添加到您的控制器...... $scope.getOptions1Idx = function(){ var mySelectedOption = $scope.child; var i = 0; for(i=0;i< option1Options.length;i++){ if(option1Options[i]==mySelectedOption){ ...
-
问题是,您对所有选择使用相同的范围变量。 您可以将所选选项存储在数组中,如下所示: function TestCtrl($scope) { $scope.items = [ { id: 1, class: 1 }, { id: 2, class: 2 }, { id: 3, class: 1 }, ]; $scope.classes = [ { name: "class 1", id: 1}, { name: "class 2", id: ...
-
angular ng-options指令最终选择多个项目(angular ng-options directive ends up selecting multiple items)[2024-04-09]
问题 我能够在这里重现你的问题。 我在$scope.selectedFacility上设置了一个$scope.selectedFacility ,以查看模型实际更新的时间。 $scope.$watch('selectedFacility', function(newVal, oldVal) { console.log(newVal); console.log(oldVal); }); 手表在开始时被调用一次: [Log] null (main.js, line 17) [Log] null (ma ... -
使用ng-options选择动态地将类分配给ng-repeat项目(Dynamically allocating class to ng-repeat items with ng-options select)[2021-09-15]
不要通过javascript手动添加类名,而是使用Angular的ngClass指令。- Instead of adding the classname manually through java ...
-
因为当您重新options值时,必须在options之前使用this options指向当前options 。 handleChange(event) { console.log(event.target.value); //this to indicate options from current class this.options = [{id: 0, name:"First"}, {id: 1, name:"Second"}, {id: 2, name:"Third"}]; ...
-
使用角度多选我想在加载时显示选定的选项(Using angular-multi-select I want to show selected options upon load)[2022-11-24]
我知道了。 我实际上只需要在$ scope.companies中设置每个项目,使其具有等于true的'ticked'属性:) I got it. I actually just had to set each item in $scope.companies to have a 'ticked' attribute that equals true :) -
Angular有多个选择,必须选择唯一的选项(Angular with multiple selects that must have unique options selected)[2023-07-11]
我搁置了一段时间,但今天早上回来了。 我能够想出一个可行的解决方案。 这是我写的。 可能不是最优雅的方式,但它适用于我的目的:AngularTest 你可以通过一个顶部选择器和一个下拉菜单来略微简化这一点。 然后,当您单击“添加”时,它会将当前选定的项目插入到选定的“浇头”部分,然后从可用列表中删除该选项。 如果您感觉聪明,您还可以将下拉列表绑定到不包含已选择项目的计算项目集合。 (underscore.js也将极大地帮助这个)。 ( 小提琴 ) JS // Class to represent a possible topping function Topping(name) { var self = this; self.name = ...角度选择默认选项(Angular Select Default Options)[2020-06-04]
有两种方法: 使用两个选项进行切换 看一个例子 编写自定义指令 There are two ways: Use two selects to switch see an example Write a custom directive相关文章
更多- 使用eclipse创建maven项目图文详解
- Running Solr with Maven
- Hadoop与Eclipse
- eclipse在部署工程时出现异常
- 关于eclipse的设置问题
- [ solr入门 ] - 在eclipse中发布solr
- 请教如何在eclipse中将maven项目部署到centos服务器上去?
- nutch 1.7导入Eclipse
- solr源码导入eclipse
- Eclipse安装Gradle插件
最新问答
更多- 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
- 如何通过引用返回对象?(How is returning an object by reference possible?)
- 矩阵如何存储在内存中?(How are matrices stored in memory?)
- 每个请求的Java新会话?(Java New Session For Each Request?)
- css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
- 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
- xcode语法颜色编码解释?(xcode syntax color coding explained?)
- 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
- 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
- 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
- 西安哪有PLC可控制编程的培训
- 在Entity Framework中选择基类(Select base class in Entity Framework)
- 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
- 电脑二级VF有什么用
- Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
- 金华英语角.
- 手机软件如何制作
- 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
- 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
- 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
- Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
- 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
- python的访问器方法有哪些
- DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
- 在Ruby中对组合进行排序(Sorting a combination in Ruby)
- 网站开发的流程?
- 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
- 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
- 透明度错误IE11(Transparency bug IE11)
- linux的基本操作命令。。。