我在Spring3.1独立环境下开发.
我正在尝试通过jconsole远程连接我的应用程序.它在本地工作但是当我将我的应用程序部署到linux机器时它会有时间.
我正在使用守护进程来运行我的环境.
这是我在run.sh脚本中添加的内容:
-Dcom.sun.management.jmxremote \
-Dcom.sun.management.jmxremote.port=6969 \
-Dcom.sun.management.jmxremote.ssl=false \
-Dcom.sun.management.jmxremote.authenticate=false \
com.mypackage.daemon.FixDaemon
Run Code Online (Sandbox Code Playgroud)
和applicationContext.xml里面:
<context:mbean-server />
<context:mbean-export />
Run Code Online (Sandbox Code Playgroud)
现在在做netstat之后的linux机器上就是我们看到的:
[root@ logs]# netstat -an | grep 6969
tcp 0 0 :::6969 :::* LISTEN
Run Code Online (Sandbox Code Playgroud)
所以看起来好像在听.
但是当我在jconsole界面中添加我的ip:6969时,我得到连接失败的弹出窗口.
知道我做错了什么吗?
谢谢,雷.
尝试使用Maven安装模块时,会引发以下错误:
org.jasypt.exceptions.EncryptionOperationNotPossibleException:
Encryption raised an exception.
A possible cause is you are using strong encryption algorithms and you have not
installed the Java Cryptography Extension (JCE) Unlimited Strength
Jurisdiction Policy Files in this Java Virtual Machine
Run Code Online (Sandbox Code Playgroud)
应用程序属性的编码如下:
app.check.url=ENC(sCO3322RNYdt3wPfO04GoaN9PijwJzUcn9rb4ggHymA\=)
Run Code Online (Sandbox Code Playgroud)
我的弹簧配置如下所示:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
<bean id="placeholderConfig" class="org.jasypt.spring.properties.EncryptablePropertyPlaceholderConfigurer">
<constructor-arg ref="configurationEncryptor"/>
<property name="ignoreResourceNotFound">
<value>true</value>
</property>
<property name="ignoreUnresolvablePlaceholders">
<value>false</value>
</property>
<property name="locations">
<list>
<!-- These always come from the file system in ./conf/appCtx -->
<value>file:../application.properties</value>
</list> …Run Code Online (Sandbox Code Playgroud) 我正在使用AbstractAnnotationConfigDispatcherServletInitializer配置我的Web应用程序.我还有一个@Configuration用于创建几个bean的类.在这个类中,我使用@PropertySource注释来加载各种设置的属性文件(例如数据库连接细节).
目前,我使用Maven配置文件和Ant任务为我的运行时环境创建正确的属性文件.也就是说,我让Maven在构建时将"prod.properties"或"dev.properties"移动到"application.properties"(该类使用).我想要做的是使用Spring配置文件来消除这种情况.我希望能够做到以下几点:
@PropertySource( value = "classpath:/application-${spring.profiles.active}.properties")
Run Code Online (Sandbox Code Playgroud)
我还想在不使用任何XML的情况下设置配置文件.所以我需要根据系统属性的存在来设置配置文件.例如,
String currentEnvironment = systemProperties.getProperty("current.environment");
if (currentEnvironment == null) {
((ConfigurableEnvironment)context.getEnvironment()).setActiveProfiles("production");
} else {
((ConfigurableEnvironment)context.getEnvironment()).setActiveProfiles(currentEnvironment);
}
Run Code Online (Sandbox Code Playgroud)
不过,我不知道我能在哪里做到这一点.根据相关问题的答案,可以createRootApplicationContext在我的初始化器类中重写该方法.但是,该答案还依赖于在设置配置文件之前加载的配置类.
我想做什么?如果是这样,怎么样?
我使用注释来标记应该在事务中执行的方法.
但是,在一个地方我需要transactionManager.rollback()手动完成,没有注释.我怎样才能获得transactionManager对象?
如何在Java(Spring 3.1)中启用@Required注释?不是在xml中,而是在Java中.还有哪个注释我把这个启用?在@Feature下(在@FutureConfiguration或@Bean中(在@Configuration中)?
编辑:
@Feature
public MvcAnnotationDriven annotationDriven(ConversionService conversionService) {
return new MvcAnnotationDriven().conversionService(conversionService)
.argumentResolvers(new CustomArgumentResolver());
}
Run Code Online (Sandbox Code Playgroud)
这是否支持所有注释?
这是我视图的一个片段,当点击超链接时,我需要将两个名为solicitudId和detailId的参数发送到控制器中的方法
<tr>
<td>${user.loginName}</td>
<td>${user.phone}</td>
<td>${user.address}</td>
<td><a href="/enable?solicitudId=${user.solicitudId}&detailId=${user.detail}">Enable</a></td>
tr>
Run Code Online (Sandbox Code Playgroud)
//控制器
@RequestMapping(value="/enable", method=RequestMethod.GET)
public String enableUser(Model model){
try{
//How should I get the values from the parameters solicitudId and detailId?
}catch(Exception e){
e.printStackTrace();
}
return null;
}
Run Code Online (Sandbox Code Playgroud)
提前致谢!
我正在使用MongoDB和Spring 3.我有以下域对象:
@Document(collection = "users")
public class User {
@Id
private String id;
private List<Post> posts;
}
Run Code Online (Sandbox Code Playgroud)
我想将添加Post到User,但什么是最好/最有效的方式做到这一点?我可以看到一种以编程方式执行此操作的方法 - 找到用户,将新的帖子对象添加到列表中并再次保存用户 - 但我认为这不是非常优雅或高效.
从文档中我似乎需要使用$push运算符,但我似乎无法找到如何使用Spring的MongoTemplate执行此操作的任何示例.谁能提供一个例子?
我有一个像3.0这样的xml:
<bean id="dataSource" destroy-method="close" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="${jdbc.driverClassName}" />
<property name="url" value="${jdbc.internal.url}" />
<property name="username" value="${jdbc.internal.username}" />
<property name="password" value="${jdbc.internal.password}"/>
</bean>
Run Code Online (Sandbox Code Playgroud)
我想在使用时将其转换为3.1 beans:profile但是,当我尝试将其更改为:
<beans profile="dev">
<bean id="dataSource" destroy-method="close" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="${jdbc.driverClassName}" />
<property name="url" value="${jdbc.internal.url}" />
<property name="username" value="${jdbc.internal.username}" />
<property name="password" value="${jdbc.internal.password}"/>
</bean>
</beans>
Run Code Online (Sandbox Code Playgroud)
我得到的错误如下:
Invalid content was found starting with element 'bean'. One of '{"http://www.springframework.org/schema/beans":beans}'
Run Code Online (Sandbox Code Playgroud)
题
我如何使用它,beans:profile以便仅在活动配置文件时调用此特定bean定义dev
更新 我的bean定义是:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.1.xsd
http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.1.xsd">
Run Code Online (Sandbox Code Playgroud) 我正在为我的应用程序使用Spring 3.1.0 JAR.我通过命令名称将我的bean类映射到了视图,我对映射它没有问题.
问题是int我的bean类中有一个变量:
private int id;
Run Code Online (Sandbox Code Playgroud)
当我用这个变量映射时<'form:input path="id" />',它0在文本框中给出了我不想要的默认值.我怎么能摆脱这个?
我有一个控制器工作正常,它可以注册和更新一个实体,以及如何分别创建表格以分别保存和更新实体
@RequestMapping(value="/registrar.htm", method=RequestMethod.GET)
public String crearRegistrarFormulario(Model model){
…
}
@RequestMapping(value="/{id}/actualizar.htm", method=RequestMethod.GET)
public String crearActualizarFormulario(@PathVariable("id") String id, Model model){
…
}
Run Code Online (Sandbox Code Playgroud)
直到这里我没有问题.
我的问题是关于@InitBinder
我需要使用相同的实体Deportista(运动员),一个特殊的设置来保存和更新.例如
@InitBinder
public void registrarInitBinder(WebDataBinder binder) { // register or save
logger.info(">>>>>>>> registrarInitBinder >>>>>>>>>>>>>");
…
CustomDateEditor customDateEditor = new CustomDateEditor(...
…
}
@InitBinder
public void actualizarInitBinder(WebDataBinder binder) { // update
logger.info(">>>>>>>> actualizarInitBinder >>>>>>>>>>>>>");
…
CustomDateEditor customDateEditor = new CustomDateEditor(...
…
binder.setDisallowedFields(…) //I need this only for update
}
Run Code Online (Sandbox Code Playgroud)
我看过以下内容:
这些链接中提到变通不同entities,例如 …
spring-3 ×10
spring ×7
java ×6
spring-mvc ×4
encryption ×1
forms ×1
jasypt ×1
jmx ×1
jstl ×1
linux ×1
maven ×1
mongodb ×1
mongodb-java ×1
spring-4 ×1
transactions ×1
view ×1