我正在开发我的第一个方面,我遇到了以下麻烦.
MyAspect类:
@Component
@Aspect
public class MyAspect{
@Pointcut("execution(* com.mypackage.MyClass.method(..))")
public void sendComunication(){}
@AfterReturning("sendComunication()")
public void sendComunicationMail() {
//TODO somethings
}
Run Code Online (Sandbox Code Playgroud)
}
然后我在applicationContext中添加了"aop:aspectj-autoproxy"和aop命名空间.现在,当我尝试构建我的应用程序时,我收到此错误:
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0': Initialization of bean failed; nested exception is java.lang.IllegalArgumentException: error at ::0 can't find referenced pointcut sendComunication
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:323)
... 36 more
Caused by: java.lang.IllegalArgumentException: error at ::0 can't find referenced pointcut sendComunication
at org.aspectj.weaver.tools.PointcutParser.parsePointcutExpression(PointcutParser.java:315)
at org.springframework.aop.aspectj.AspectJExpressionPointcut.buildPointcutExpression(AspectJExpressionPointcut.java:207)
at …
Run Code Online (Sandbox Code Playgroud) 我正在开发一个java应用程序,现在我注意到一个让我困惑的奇怪行为.我有以下情况:
Integer currentIndex = 0;
doSomethings(currentIndex);
System.out.println("Print "+currentIndex);
private void doSomethings(Integer currentIndex){
//Do other things and update my current index
currentIndex++;
}
Run Code Online (Sandbox Code Playgroud)
但我总是像价值一样.我记得对象在java中像引用一样传递,而原始类型如copy.为什么我在这种情况下得0?
我应该向具有BeanItemContainer数据源的表添加一列.
这是我的情况:
我有一个实体bean
@Entity
public class MyBean implements {
@Id
private Long id;
//other properties
Run Code Online (Sandbox Code Playgroud)
}
然后在我的vaadin面板中我有这个方法
private Table makeTable(){
Table table = new Table();
tableContainer = new BeanItemContainer<MyBean>(MyBean.class);
table.setContainerDataSource(tableContainer);
table.setHeight("100px");
table.setSelectable(true);
return table;
}
Run Code Online (Sandbox Code Playgroud)
现在,我想添加一个列,使我能够删除此容器中的项目.
我能怎么做?
我使用vaadin(7.1.9)的上传组件,现在我的问题是,我不能够限制什么样的可以与上传组件向服务器发送的文件,但我还没有发现任何用于此目的的API.唯一的方法是在上传后丢弃错误类型的文件.
public OutputStream receiveUpload(String filename, String mimeType) {
if(!checkIfAValidType(filename)){
upload.interruptUpload();
}
return out;
}
Run Code Online (Sandbox Code Playgroud)
这是正确的方法吗?
我第一次使用pdfbox。现在我正在阅读网站上的一些东西Pdf
总结一下我有一个这样的pdf:
只是我的文件有很多不同的组件(textField、RadionButton、CheckBox)。对于此 pdf,我必须阅读以下值:Mauro、Rossi、MyCompany。现在我写了以下代码:
PDDocument pdDoc = PDDocument.loadNonSeq( myFile, null );
PDDocumentCatalog pdCatalog = pdDoc.getDocumentCatalog();
PDAcroForm pdAcroForm = pdCatalog.getAcroForm();
for(PDField pdField : pdAcroForm.getFields()){
System.out.println(pdField.getValue())
}
Run Code Online (Sandbox Code Playgroud)
这是读取表单组件内值的正确方法吗?对此有何建议?我在哪里可以在 pdfbox 上学到其他东西?
我是反思的新手,我正试图获得一个嵌套的字段.总结我有以下几个类:
public class Agreement{
private Long id;
private String cdAgreement;
private Address address;
//Constructor getter and setter
}
public class Address{
private Long id;
private String description;
//Constructor getter and setter
}
Run Code Online (Sandbox Code Playgroud)
现在我想得到描述字段,然后我写了这段代码:
Agreement agreement = new Agreement();
Class c = agreement.getClass();
Field f = c.getDeclaredField("address.descritpion");
Run Code Online (Sandbox Code Playgroud)
但不起作用,我得到以下异常:
java.lang.NoSuchFieldException: address.descritpion
at java.lang.Class.getDeclaredField(Class.java:1948)
Run Code Online (Sandbox Code Playgroud)
我哪里做错了?
我正在尝试使用DecimalFormat转换一些字符串值.我试着用更好的方式向你解释我的问题:
我有以下方法:
private BigDecimal loadBigDecimal(String value){
BigDecimal bigDecimalToReturn = null;
DecimalFormat df = new DecimalFormat("##.###");
bigDecimalToReturn = new BigDecimal(df.parse(value).doubleValue());
return bigDecimalToReturn;
}
Run Code Online (Sandbox Code Playgroud)
现在,如果我尝试运行该方法:
BigDeciaml dec = myObject.loadBigDecimal("120,11");
Run Code Online (Sandbox Code Playgroud)
dec的值是120.1099999999999994315658113919198513031005859375
.为什么decimalFormat会改变我的值的范围?
java ×6
vaadin ×2
vaadin7 ×2
aspectj ×1
bigdecimal ×1
pdf ×1
pdfbox ×1
reflection ×1
spring ×1
spring-aop ×1