在构建过程中,我需要由外部工具生成一些文件。对于我的最小可编译示例,我将“外部工具”简化为以下脚本:
mkdir -p target/generated-resources
echo "hello world" > target/generated-resources/myResource.txt
Run Code Online (Sandbox Code Playgroud)
现在我想在构建期间执行外部工具,并且生成的资源应包含在 war 文件中。我找不到任何有关如何完成此操作的文档,因此只是猜测我需要将生成的资源写入target/generated-resources. 那么也许这是一个问题?
我使用以下构建配置创建了一个 pom.xml 文件:
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<phase>generate-resources</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>./createResource.sh</executable>
</configuration>
</plugin>
</plugins>
</build>
Run Code Online (Sandbox Code Playgroud)
如果我运行mvn packagecreateResource.sh 脚本,则会成功执行并创建 myResource.txt 文件。但是,myResource.txt 文件不包含在生成的 .jar 文件中。
我注意到如果我添加它就会起作用
<resources>
<resource>
<directory>target/generated-resources</directory>
</resource>
</resources>
Run Code Online (Sandbox Code Playgroud)
我的构建配置,但我担心如果其他插件可能以不同的方式使用此目录,这可能会导致问题(是吗?我真的找不到有关该target目录约定的任何信息)。
另外,我更喜欢一个与通常的 Maven 约定一起使用的解决方案(如果存在这种情况的约定)。
如何在使用 maven 构建期间正确生成要包含在 jar 文件中的资源?
for example, I have queries select id, name, age, address from staffs, instead of having a list of Staff object. I'd prefer to have a list of maps, as
list{
map{
("id", 123),
("name","jackie"),
("address", "canada"),
("age",26)
}
map{
("id", 126),
("name","james"),
("address", "canada"),
("age",27)
}
}
Run Code Online (Sandbox Code Playgroud)
is that possible, and how to do that, if possible? Thanks.
我运行WebSphere 7.0 Portal.必须登录才能看到任何适用于所有portlet的信息.但另外还有一些servlet部署在同一个war文件中,可以为AJAX脚本生成一些原始数据.
目前,如果知道该特定servlet的URL,则可以绕过WebSphere Portal的身份验证.我想更改此项并检查用户当前是否已登录到Portal.我该怎么做呢?我试过((PumaHome) new InitialContext().lookup(new CompositeName(PumaHome.JNDI_NAME))).getProfile().getCurrentUser();但这会返回null.
如何从特定ID启动SQL查询...
id | name |
------------
1 | Joe |
2 | Craig |
3 | Shawn |
4 | Ryan |
5 | Seth |
Run Code Online (Sandbox Code Playgroud)
我想从ID 3开始
$strSQL = "SELECT * FROM table_name WHERE id >= 3";
Run Code Online (Sandbox Code Playgroud)
谢谢你的帮助!
我正在使用Apache HttpClient 4与REST API 进行通信,并且大部分时间我都在进行冗长的PUT操作.由于这些可能发生在不稳定的Internet连接上,我需要检测连接是否中断并且可能需要重试(使用恢复请求).
为了在现实世界中尝试我的例程,我开始了PUT操作,然后我翻转了笔记本电脑的Wi-Fi开关,导致任何数据流立即完全中断.然而,它需要一个很长的时间(可能是5分钟左右),直到最终抛出SocketException.
我怎样才能加快处理速度?我想设置一个约30秒的超时.
更新:
为了澄清,我的请求是PUT操作.因此,在很长一段时间(可能是几小时)内,唯一的操作是write()操作,并且没有读操作.read()操作有一个超时设置,但是找不到写操作.
我正在使用自己的实体实现,因此我直接写入一个OutputStream,一旦Internet连接中断,它几乎会立即阻塞.如果OutputStreams有一个超时参数,所以我可以写,out.write(nextChunk, 30000);我可以自己检测到这样的问题.其实我试过了:
public class TimeoutHttpEntity extends HttpEntityWrapper {
public TimeoutHttpEntity(HttpEntity wrappedEntity) {
super(wrappedEntity);
}
@Override
public void writeTo(OutputStream outstream) throws IOException {
try(TimeoutOutputStreamWrapper wrapper = new TimeoutOutputStreamWrapper(outstream, 30000)) {
super.writeTo(wrapper);
}
}
}
public class TimeoutOutputStreamWrapper extends OutputStream {
private final OutputStream delegate;
private final long timeout;
private final ExecutorService executorService = Executors.newSingleThreadExecutor();
public TimeoutOutputStreamWrapper(OutputStream delegate, long timeout) {
this.delegate = delegate;
this.timeout …Run Code Online (Sandbox Code Playgroud) 我有一个页面,其中包括分布在几个选项卡上的HTML表单元素.我希望用户能够切换标签而不会丢失他在表单元素上输入的数据(我还想保存不必要的数据重新加载).我仍然希望能够将某个链接传递给特定标签.
这听起来像ui-extras粘性状态应该完全符合我的需要.除了我一直没有成功地让它工作.
我研究了示例源代码,当我启动示例时,例如在controllers.js的第57行中找到的库存控制器的构造函数中使用firebug设置断点,我看到构造函数只被触发一次.然而,我的控制器构造函数一次又一次地被触发,我的应用程序的行为非常类似于粘性状态不存在,尽管如果我启用粘性状态调试它告诉我它正在做某事(停用和重新激活状态).
我发现有人声称粘性状态仅适用于此答案中的注释中的命名视图,所以我试图给我的视图命名,但这没有任何区别.
我尝试在我的标签之前插入一个明确的"根状态".
我尝试通过ng-controller或控制器定义在状态中插入控制器.
github上的例子是一个很好的炫耀,但它不仅仅是最小的,而且很难看到实际需要什么,什么不是.
什么是开始使用粘性状态所需的最小例子?(额外奖励:我的代码出了什么问题?).
作为参考,这里有一个尝试失败的傻瓜(参见历史以查看先前尝试的选择).
这是我目前失败的源代码:
var log = '';
function mkController(msg) {
return function($scope) {
// This is the constructor of a controller
// I'd expect this constructor to the first time a state is loaded.
// When switching to a sister state and back it should not be called again.
if (!$scope.random) {
// I expect the $scope object to be retained when …Run Code Online (Sandbox Code Playgroud) 我正在尝试测试Angular 2组件,它依赖于服务调用来填充数据.但是,这个服务调用promise是在另一个函数内部处理的.
this.data = null; //empty data is defined here.
public getDataMethod(){
// controller related logic
privateService.privateMethod(
(data) => {this.data = data} //the data is populated here
)
}
Run Code Online (Sandbox Code Playgroud)
我怎么能等待内部函数解决?
我读到我们可以等待承诺以"完成"来解决,但我发现的唯一例子是直接调用承诺.(不是函数内的嵌套promise)
我尝试将done方法传递给函数,它运行良好.
public getDataMethod(done){
// controller related logic
privateService.privateMethod(
(data) => {this.data = data} //the data is populated here
done(); //Calling done when the promise is resolved.
)
}
Run Code Online (Sandbox Code Playgroud)
但是,这确实使得经过测试的代码变得混乱.data在运行测试之前是否有更好的方法等待填充值?
我把jquery.js复制到了WebContent/js/jquery/jquery.js.现在我想在某些portlet中使用该文件.为此,我创建了一个liferay-portlet.xml,如下所示:
<?xml version="1.0"?>
<!DOCTYPE liferay-portlet-app PUBLIC
"-//Liferay//DTD Portlet Application 6.0.0//EN"
"http://www.liferay.com/dtd/liferay-portlet-app_6_0_0.dtd">
<liferay-portlet-app>
<portlet>
<portlet-name>MyPortletName</portlet-name>
<header-portal-javascript>/js/jquery/jquery.js</header-portal-javascript>
</portlet>
</liferay-portlet-app>
Run Code Online (Sandbox Code Playgroud)
如果我访问portlet,Liferay会生成以下行:
<script src="/js/jquery/jquery.js?browserId=firefox&minifierType=js&languageId=en_US&b=6100&t=1326630657000" type="text/javascript"></script>
Run Code Online (Sandbox Code Playgroud)
这导致WARN [404_jsp:?] /js/jquery/jquery.js在日志记录控制台中.
URL看起来是否正确?如果我有两个war文件,都包含一个具有相同路径的js文件,Liferay将如何区分这两个?
我需要做些什么才能使我的设置正常工作?
使用Liferay Portal Community Edition 6.1.0 CE(Paton/Build 6100/2011年12月15日)
我正在使用Apache HttpClient 4.3与hubic.com的API进行交互.我的最小可重复的例子只是一个班轮:
HttpClientBuilder.create().build().execute(new HttpGet("https://hubic.com"));
Run Code Online (Sandbox Code Playgroud)
然而,抛出:
Exception in thread "main" javax.net.ssl.SSLException: Received fatal alert: protocol_version
at sun.security.ssl.Alerts.getSSLException(Alerts.java:208)
at sun.security.ssl.Alerts.getSSLException(Alerts.java:154)
at sun.security.ssl.SSLSocketImpl.recvAlert(SSLSocketImpl.java:1991)
at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1104)
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1343)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1371)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1355)
at org.apache.http.conn.ssl.SSLConnectionSocketFactory.createLayeredSocket(SSLConnectionSocketFactory.java:275)
at org.apache.http.conn.ssl.SSLConnectionSocketFactory.connectSocket(SSLConnectionSocketFactory.java:254)
at org.apache.http.impl.conn.HttpClientConnectionOperator.connect(HttpClientConnectionOperator.java:117)
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:314)
at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:363)
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:219)
at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:195)
at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:86)
at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:108)
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:186)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:106)
Run Code Online (Sandbox Code Playgroud)
如果我运行以下是输出System.setProperty("javax.net.debug", "all");:
trustStore is: /usr/lib/jvm/java-8-oracle/jre/lib/security/cacerts
trustStore type is : jks
trustStore provider is :
init truststore
adding as trusted cert: [... extremely large list ...] …Run Code Online (Sandbox Code Playgroud) 我正在使用 Ubuntu,并想使用 IntelliJ IDEA 开发 tomcat 应用程序。
我安装了 tomcat8-user 并创建了一个实例:
sudo apt-get install tomcat8-user
tomcat8-instance-create /home/myhome/tomcat
Run Code Online (Sandbox Code Playgroud)
但是,当我尝试在 IDEA 中配置 tomcat 时,我只收到消息“所选目录不是有效的 Tomcat 主目录”:

但是,当我单击“确定”时,出现错误“未找到应用程序服务器库”:
问题是什么?我该如何解决?