LAMP是一个从左到右(从下到上)定义为Linux/Apache/MySQL/PHP的堆栈,或者通常可以将其视为操作系统/ Web服务器/数据库/脚本语言.在通用形式中,您可以在任何操作系统中弹出,例如Windows而不是Linux以获取WAMP或放入其他数据库,甚至可以运行除PHP以外的其他语言,如Ruby.但是,通常你只有一件东西.一个数据库,一个操作系统,一个Web服务器,但您的应用程序可能会从一个堆栈转换到另一个堆栈,并且进行一些有限的更
我已经在LAMP堆栈中进行了几年的开发,我一直在阅读有关JSF以及组件库RichFaces和IceFaces的内容.从支持AJAX的组件构建网站UI的整个想法,并获得各种漂亮的东西,如验证,以及免费的混乱AJAX调用真的很令人兴奋.
问题是我很难理解通用组件构成Java EE堆栈的原因.根据我的研究,您似乎有以下类别来构建"Java EE堆栈":
Java EE应用服务器 - JBoss,Tomcat
数据库 - MySQL,Oracle
数据库抽象 - Hibernate,JPA
支持JSF Ajax的组件库 - ICEFaces,RICHFaces
我觉得我肯定错过了一些东西.我不确定Seam或Spring适合这个.Hibernate也是使用JPA的东西吗?或者JPA是一个功能齐全的API,我可以轻松使用它?容器在哪里适合这个?我可以出去找一个容器在我的Java EE应用服务器上运行吗?此外,Maven在哪里适合所有这些?从我收集的内容来看,它似乎不是Web服务堆栈的一部分,而是在部署之前使用的工具.
我一直在阅读Rainer Eschen的ICEfaces 1.8,这个图由他作为一种Java EE堆栈呈现.我的猜测是AppFuse是针对Java EE的,因为XAMPP是针对LAMP的.真的吗?如果有人可以分解下图中的各个部分以及它们如何组合在一起,那将非常有用.
ICEcube架构图http://img191.imageshack.us/img191/336/icecubearchitecture.png
我知道这些是各种各样的问题.如果我没有问你认为我应该知道的事情,请随意把它丢掉,或者如果我说错了,请纠正我!Java EE堆栈以及与它一起使用的所有部分至少可以说是令人生畏的.在我深入研究并开始构建任何东西之前,我只是希望能够很好地处理高级视图.
谢谢!
我在eclipse中有一个maven 3项目,其结构如下.应用程序项目充当所有其他应用程序的父项目.我已经从app项目(第一个pom)中包含了pom.xml,并从app-web项目中包含了pom.xml.(第二个pom)
app
app-ear
app-ejg
app-web
我遇到的问题是我可以在app-web/pom.xml的有效pom中看到来自父项的依赖项,但app-web项目中的java类无法从这些依赖项导入.我得到"导入com.fasterxml无法解析".我也有app-ejb项目的这个问题.我不认为这只是一个"日食错误".如果我尝试从app项目mvn clean install我得到编译错误抱怨同样的事情.
顺便说一句,我所做的唯一改变就是将依赖项从子项的pom.xml中移出并转移到父项中.我希望尽可能集中内容,并尽可能将项目配置保持为DRY.在将依赖关系向上移动之前,事情很好.我正在为安装了m2e,m2e-wtp和WTP补丁的Java EE开发人员使用Eclipse Juno.
应用程序/ pom.xml的
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.boardgamebuilder</groupId>
<artifactId>app</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<name>app application</name>
<modules>
<module>app-ejb</module>
<module>app-web</module>
<module>app-ear</module>
</modules>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java-version>1.6</java-version>
<org.slf4j-version>1.7.2</org.slf4j-version>
<com.fasterxml.jackson-version>2.1.1</com.fasterxml.jackson-version>
</properties>
<dependencyManagement>
<dependencies>
<!-- JSON handler -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>${com.fasterxml.jackson-version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>${com.fasterxml.jackson-version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${com.fasterxml.jackson-version}</version>
</dependency>
<!-- RESTful servlet -->
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-server</artifactId>
<version>1.16</version>
</dependency>
<!-- Logging -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${org.slf4j-version}</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId> …Run Code Online (Sandbox Code Playgroud) 如此处所述(https://github.com/liquibase/liquibase-hibernate/issues/74)我遇到了使liquibase-hibernate扩展正常工作的问题.我想我已经完成了所有设置,但似乎我一直遇到奇怪的问题.我觉得我错过了一些简单的东西,但我想我已按照提供的所有说明进行操作.
我正在使用liquibase 3.3.2,Hibernate 4.3.0.Final,java 1.7.0_71和liquibase-hibernate4-3.5.jar.我的CLASSPATH环境变量是空的,但liquibase shell脚本会添加一些东西.当我使用正常的liquibase命令进行交互时,我从$ LIQUIBASE_HOME/lib /目录中删除了没有扩展名的扩展名,它可以正常工作.我用DEBUG输出重新启动命令以提供更多信息.
$ echo $CLASSPATH
$ java -version
java version "1.7.0_71"
Java(TM) SE Runtime Environment (build 1.7.0_71-b14)
Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)
$ liquibase --version
Liquibase Version: 3.3.2
$ liquibase diffChangeLog
//The below is the stuff liquibase is adding to my classpath
.:/c/repos/ServeDirtyLibsInJava/liquibaseLib/liquibase.jar:/c/repos/ServeDirtyLibsInJava/liquibaseLib/lib/liquibase-hibernate4-3.5.jar:/c/repos/ServeDirtyLibsInJava/liquibaseLib/lib/snakeyaml-1.13.jar
WARNING 1/19/15 12:42 AM: liquibase: Can not use class liquibase.ext.hibernate.database.HibernateEjb3Database as a Liquibase service because org.hibernate.dialect.Dialect is not in the classpath
WARNING 1/19/15 12:42 AM: …Run Code Online (Sandbox Code Playgroud) https://www.typescriptlang.org/docs/handbook/declaration-merging.html
上述链接提供了有关与接口合并的声明的信息。我希望能够使用具有通用组件的界面来做到这一点。我目前正在使用 Typescript 3.0.3。
这做我想要的,但我不明白为什么我不能用声明合并做同样的事情。
interface MyRouteComponentProps<P, C extends StaticContext = StaticContext> extends RouteComponentProps<P, C> {
loadCandidateFromQueryParam: (candidateId: number) => void
}
class CandidateDetailContainer extends React.Component<MyRouteComponentProps<RouteMatchProps>, {}> {
public componentWillMount() {
this.props.loadCandidateFromQueryParam(Number(this.props.match.params.candidateId));
}
Run Code Online (Sandbox Code Playgroud)
为什么这不起作用?
interface RouteComponentProps<P, C extends StaticContext = StaticContext> {
loadCandidateFromQueryParam: (candidateId: number) => void
}
class CandidateDetailContainer extends React.Component<RouteComponentProps<RouteMatchProps>, {}> {
Run Code Online (Sandbox Code Playgroud)
它似乎完全覆盖了 RouteComponentProps 的整个定义,而不是合并它们。我收到与从未使用过的 P 和 C 相关的错误(如果合并了定义,那么我希望这些错误会消失,因为它们在主定义中使用)。然后我收到一个关于“匹配”字段不存在的错误。同样,原始定义中存在的另一个字段。
作为参考,这里是我试图合并的原始定义。
export interface RouteComponentProps<P, C extends StaticContext = StaticContext> {
history: H.History;
location: H.Location;
match: match<P>;
staticContext: C | …Run Code Online (Sandbox Code Playgroud) 我正在使用 Mockito 1.9.5 和 Powermock 1.5.2
这是我的测试代码
@RunWith(PowerMockRunner.class)
@PrepareForTest(Jsoup.class)
public class PowerMockTest {
@Test
public void test1() throws IOException {
mockStatic(Jsoup.class, RETURNS_DEEP_STUBS);
Jsoup.connect("foo");
}
}
Run Code Online (Sandbox Code Playgroud)
当我运行它时,我得到一个例外。当 Powermock 试图返回答案时,它看起来像是将统治权移交给 Mockito,而 Mockito 没有正确处理它(我确定这与静态模拟有关)。
有没有人知道一个很好的“答案”实现,它会做与 RETURN_DEEP_STUBS 相同的事情,像 Jsoup 这样的静态类会返回自身?
如果我对 Jsoup 的静态方法的每个单独调用进行存根,那么我可以让它工作,但我宁愿不必这样做。
java.lang.NullPointerException
at org.mockito.internal.stubbing.defaultanswers.ReturnsDeepStubs.getMock(ReturnsDeepStubs.java:47)
at org.mockito.internal.stubbing.defaultanswers.ReturnsDeepStubs.answer(ReturnsDeepStubs.java:39)
at org.mockito.internal.handler.MockHandlerImpl.handle(MockHandlerImpl.java:93)
at org.powermock.api.mockito.internal.invocation.MockitoMethodInvocationControl.performIntercept(MockitoMethodInvocationControl.java:260)
at org.powermock.api.mockito.internal.invocation.MockitoMethodInvocationControl.invoke(MockitoMethodInvocationControl.java:192)
at org.powermock.core.MockGateway.doMethodCall(MockGateway.java:105)
at org.powermock.core.MockGateway.methodCall(MockGateway.java:60)
at org.jsoup.Jsoup.connect(Jsoup.java)
at CommissionChecker.PowerMockTest.test1(PowerMockTest.java:42)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at org.junit.internal.runners.TestMethod.invoke(TestMethod.java:66)
at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$PowerMockJUnit44MethodRunner.runTestMethod(PowerMockJUnit44RunnerDelegateImpl.java:310)
at org.junit.internal.runners.MethodRoadie$2.run(MethodRoadie.java:86)
at org.junit.internal.runners.MethodRoadie.runBeforesThenTestThenAfters(MethodRoadie.java:94)
at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$PowerMockJUnit44MethodRunner.executeTest(PowerMockJUnit44RunnerDelegateImpl.java:294)
at org.powermock.modules.junit4.internal.impl.PowerMockJUnit47RunnerDelegateImpl$PowerMockJUnit47MethodRunner.executeTestInSuper(PowerMockJUnit47RunnerDelegateImpl.java:127)
at org.powermock.modules.junit4.internal.impl.PowerMockJUnit47RunnerDelegateImpl$PowerMockJUnit47MethodRunner.executeTest(PowerMockJUnit47RunnerDelegateImpl.java:82)
at …Run Code Online (Sandbox Code Playgroud) I'm trying to put Spring's custom Tomcat classloader into my embedded Tomcat instance that I use for integration tests in my Gradle project because I plan on using load time weaving. It works fine in my normal install when I place spring-instrument-tomcat-3.2.5.RELEASE.jar into the apache-tomcat-7.0.40/lib folder, but how do I access that folder of an embedded Tomcat instance and place the jar in there before the boostrap classloader finds it?
https://github.com/bmuschko/gradle-tomcat-plugin/
Before making the suggested change I was getting this …
我写了一个WebDataBinder的自定义实现.在将来,我想对它进行增强,以便它在类本身上查找注释,并确定它是否应该绑定数据.
如何将此类注入Spring上下文而不是WebDataBinder?
我想要的是,如果我运行此代码,我的WebDataBinder版本将被注入,而不是默认的Spring.
@Controller
public class MyFormController {
@InitBinder
public void initBinder(WebDataBinder binder) {
// ...
}
// ...
}
Run Code Online (Sandbox Code Playgroud)
我自定义的WebDataBinder实现.它允许我按类而不是方法名称排除数据绑定.
package com.companyname.spring;
import org.springframework.beans.MutablePropertyValues;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.WebDataBinder;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class CustomDataBinder extends WebDataBinder {
List<Class> disallowedClasses = new ArrayList<>();
public CustomDataBinder(Object target) {
super(target);
}
public CustomDataBinder(Object target, String objectName) {
super(target, objectName);
}
public CustomDataBinder disallowClass(Class... classes) {
Collections.addAll(disallowedClasses, classes);
return this;
}
@Override
protected void doBind(MutablePropertyValues mpvs) {
if(disallowedClasses.contains(getTarget().getClass())) {
if …Run Code Online (Sandbox Code Playgroud) 当我使用Capybara的has_selector时?它等待并重试尝试像find()方法一样找到dom节点吗?我在下面的文档中找不到任何有用的信息.我对答案很感兴趣,但我真的更感兴趣的是我如何从ruby文档中推断出这些信息(这总是让我在浏览时遇到问题).
http://rubydoc.info/github/jnicklas/capybara/master/Capybara/Node/Finders#find-instance_method
尝试有效地检查对象的新副本是否具有任何不同的字段,如果有,则更新本地副本并记下它.如果任何字段发生更改,则需要将对象持久保存到数据库中.如果我不需要,我不想进行调用,因此布尔值.
我没有想到一个更好的方法来做到这一点而不使用反射,但我不想在这里使用反射,因为缺乏编译器支持的安全性(会有字段名称的字符串引用),而不是所有的字段是相同的类型(我有一些Java 8 Instant字段).
我真正想要避免的是在修改字段时必须记住在同步方法中添加或减去的簿记.显然减法并不是什么大问题,因为该方法会中断,但如果有人不记得更新新字段,则添加会很吓人.
public boolean syncWithFieldsFrom(User currentUser) {
boolean doesUserNeedUpdating = false;
if (!StringUtils.equals(email, currentUser.email)) {
email = currentUser.email;
doesUserNeedUpdating = true;
}
if (!StringUtils.equals(firstName, currentUser.firstName)) {
firstName = currentUser.firstName;
doesUserNeedUpdating = true;
}
if (!StringUtils.equals(lastName, currentUser.lastName)) {
lastName = currentUser.lastName;
doesUserNeedUpdating = true;
}
if (!StringUtils.equals(fullName, currentUser.fullName)) {
fullName = currentUser.fullName;
doesUserNeedUpdating = true;
}
return doesUserNeedUpdating;
}
Run Code Online (Sandbox Code Playgroud) 当我尝试在 @Preauthorize 注释中使用“或”运算符时,出现以下错误。
java.lang.IllegalArgumentException: Failed to evaluate expression '#authenticatingUser.id == #id or hasRole('ROLE_ADMIN')'
Run Code Online (Sandbox Code Playgroud)
我认为我的语法是正确的,如以下文档中的“或”示例所示。
http://docs.spring.io/spring/docs/4.0.x/spring-framework-reference/html/expressions.html
并且 Spring Security 明确表示它使用“Spring EL 表达式”
http://docs.spring.io/spring-security/site/docs/3.0.x/reference/el-access.html
但是我还没有在网上看到任何关于在 @Preauthorize 注释中使用布尔“或”运算符的人的例子。
这是控制器代码的完整性。表面上我希望用户能够更改自己的密码或管理员。我已经成功地单独使用了 the#authenticatingUser.id == #id和 the hasRole('ROLE_ADMIN'),但是使用了 或 我得到了一个错误。
@RequestMapping(value = "{id}", method = RequestMethod.PUT)
@ResponseBody
@PreAuthorize("#authenticatingUser.id == #id or hasRole('ROLE_ADMIN')")
public User newPassword(@PathVariable int id, @RequestParam String newPassword, @ModelAttribute User authenticatingUser) {
User user = userService.findById(id);
user.setPassword(newPassword);
return userService.save(user);
}
Run Code Online (Sandbox Code Playgroud)