spring boot aop拦截日志问题 5C

写了一个aspect用于拦截日志并记录到数据库,注入了一个LogSvc用于写日志到数据库,只要在logsvc
的writeLog()方法加了@Transaction注解,启动就会报错“the bean 'logSvc' could not be injected as a 'com.erong.acct.batch.service.generalsvc.LogSvc' because it is a JDK dynamic proxy that implements:

Action:

Consider injecting the bean as one of its interfaces or forcing the use of CGLib-based proxies by setting proxyTargetClass=true on @EnableAsync and/or @EnableC
aching.”

在bootstrap.yml开启“ proxy-target-class: true”也没用,求大神指导!!!

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
spring aop 事务拦截问题

spring boot 在spring中配置aop 事务管理,其中有一条是这样的 ``` source.addTransactionalMethod("is*", txAttr_REQUIRED_READONLY); ``` 配置了这个之后,如果接口中有方法是以“is”开头的,那么它的事务就被设置成只读 我的问题是:如果我偏要用“is”开头来命名一个方法,那我可以用什么样的注解或者其它方式,将该方法设置成不是只读。 自己测试过了,在方法前面添加 **@Transactional(readOnly = false)** 并没有作用

Spring Aop 拦截dao层接口

我的dao层写的是接口,,,,实现是mapper.xml 现在我要拦截 dao 层的 update 和delete方法, 但不管我 用jdk的动态代理 还是 cglib 的代理 都无法拦截, 但有趣的是service 层可以拦截,,,,但也只能拦截 用业务对象访问的方法, 对于 方法里调用的其他方法 无法拦截,,,,,,,抓狂 求大神指教

spring boot 切面 自定义注解无法使用在启动类的问题

我想使用spring boot 的切面进行对controller的返回进行统一处理,然后切点的要求是controller类,使用了自定义的启用注解(EnableGlobal),且未使用自定义的排除注解(ExcludeGlobal),但又不想在每个controller上面都写一个@EnableGlobal,想把@EnableGlobal写在启动类上面,但是不生效,各位大神有没有什么好的解决办法? ![图片说明](https://img-ask.csdn.net/upload/201901/20/1547954239_882510.png) ![图片说明](https://img-ask.csdn.net/upload/201901/20/1547954124_540916.png)

spring aop切面没有执行

![图片说明](https://img-ask.csdn.net/upload/201606/22/1466584027_247491.png) 根据包名,跳转到不同的方法,类是DataSourceInterceptor,但是没有进入

如何拦截Mybatis的所有update方法,insert方法

我希望能在所有insert后把记录扔到消息队列里。能否有什么办法用AOP拦截所有的insert操作

spring aop 配置后没有反应,不报错进不去切面方法

``` <aop:config> <aop:aspect ref="aopCheck"> <aop:pointcut id="target" expression="execution(* com.dlb.frame.test.aop.Common.excute())" /> <aop:before method="checkUser" pointcut-ref="target" /> <aop:after method="addUserLog" pointcut-ref="target" /> </aop:aspect> </aop:config> ``` ``` public class Common{ public void execute() { System.out.println("--普通类--"); } } ``` ``` public class AopCheck { public void checkUser() { System.out.println("--check User--"); } public void addUserLog() { System.out.println("--addUserLog--"); } } ``` ``` public class TestAop { public static void main(String[] args) { ApplicationContext applicationContext = new ClassPathXmlApplicationContext("applicationContext.xml"); Common common = (Common) applicationContext.getBean("common"); common.execute(); } } ``` 六月 15, 2017 3:12:23 下午 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions 信息: Loading XML bean definitions from file [D:\workspace\eclipse\my\build\classes\spring-beans.xml] --普通类-- 就是没有反应怎么回事啊,也没有报错

Spring AOP中使用@pointcut("@within(xxxx)") 对没有public方法的类未生成proxy (模板模式的实现)

问题已发: http://stackoverflow.com/questions/12559713/aspectj-expession-within-doesnt-effect-on-concrete-class-which-doesnt-have 纠结几天了, 谢谢~~

SpringBoot拦截不到异常

代码是这样子的![图片说明](https://img-ask.csdn.net/upload/201808/06/1533539988_419953.png) 这个故意查找数据库中没有的数据异常被拦截到了![](https://img-ask.csdn.net/upload/201808/06/1533539638_76434.png) 这种404的问题居然拦截不到![](https://img-ask.csdn.net/upload/201808/06/1533539664_377579.png) 还有这个异常我干脆也写到第一张图的数组里面去了也拦截不到![](https://img-ask.csdn.net/upload/201808/06/1533539733_197044.png) 这是为什么?

通过mybatis拦截器获取到执行的sql语句,如果我的service层报错,怎么才能让拦截器中的sql语句不保存下来

问题描述:程序记录每一条增,改,更新sql,其实获取的sql语句是在真正执行前通过拼接方式获得的完整的即将执行的sql语句,但是当service报错时,这些语句还是会记录下来,我想问的是怎么能避免这种情况,当service报错时,mybatis拦截器拦截下来的sql语句不记录

Jersey+Spring程序中如何实现拦截器

如题,项目中采用了Jersey+Spring实现Restful webservice,现在要对接口进行身份验证,方案已经确定,但如何实现类似于struts或SpringMVC的interceptor的效果?对所有请求进行身份验证 1,备选方案是利用J2EE的filter 2,想通过Spring的AOP来实现,切面是Jersey的Resource,但怎样注入HttpServletRequest呢?

Spring注解实现Aop,找不到@Pointcut注解下的方法标签

各类中感觉是没有什么问题,我也查找了很多相关资料,也未能发现问题所在。 使用的是Eclipse,jdk8。 此项目导入了aspectjrt.jar、aspectjweaver.jar、cglib-nodep-2.1_3.jar、spring-2.5.jar。 我也换过其它版本的Spring包,问题照旧。 求大神们帮忙看看是什么情况,谢谢 ![此为抛出的异常,此异常是说在@berfore中没有找到自己定义的那个@Pointcut方法标签??可以这样理解吗](https://img-ask.csdn.net/upload/201708/24/1503564328_211138.png) ![切面类](https://img-ask.csdn.net/upload/201708/24/1503564385_377781.png) ![xml配置](https://img-ask.csdn.net/upload/201708/24/1503564409_528944.png) ![测试类](https://img-ask.csdn.net/upload/201708/24/1503565946_414294.png) ![实现了接口](https://img-ask.csdn.net/upload/201708/24/1503566056_989089.png)

springmvc拦截器拦截可以处理非法字符吗?

我拦截请求,并对请求的参数做了过滤 如图: ![图片说明](https://img-ask.csdn.net/upload/201601/28/1453949481_34097.png) 然后到了controller里面 参数并没有改变 ,请问是我解决方法的问题吗?这种方法行的通吗?还是少了些东西?谢谢大神 ![图片说明](https://img-ask.csdn.net/upload/201601/28/1453949560_969027.png)

Spring中MethodInterceptor相关

Spring Ctrl加左键点击MethodInterceptor显示Source not found 怎么处理

SpringBoot程序运行异常,ImageLoader bean冲突

Spring Boot+MyBatis程序 源程序是在另一个服务器上可以运行的,但是转到我的电脑上运行时遇到了bean冲突问题,com.sun.javafx.tk.ImageLoader与com.sun.javafx.iio.ImageLoader冲突,似乎是导包出现问题了?还是Java环境变了什么的 给出ConflictingBeanDefinitionException异常信息: org.springframework.context.annotation.ConflictingBeanDefinitionException: Annotation-specified bean name 'imageLoader' for bean class [com.sun.javafx.tk.ImageLoader] conflicts with existing, non-compatible bean definition of same name and class [com.sun.javafx.iio.ImageLoader] at org.springframework.context.annotation.ClassPathBeanDefinitionScanner.checkCandidate(ClassPathBeanDefinitionScanner.java:348) ~[spring-context-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.mybatis.spring.mapper.ClassPathMapperScanner.checkCandidate(ClassPathMapperScanner.java:237) ~[mybatis-spring-1.3.0.jar:1.3.0] at org.springframework.context.annotation.ClassPathBeanDefinitionScanner.doScan(ClassPathBeanDefinitionScanner.java:286) ~[spring-context-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.mybatis.spring.mapper.ClassPathMapperScanner.doScan(ClassPathMapperScanner.java:164) ~[mybatis-spring-1.3.0.jar:1.3.0] at org.mybatis.spring.annotation.MapperScannerRegistrar.registerBeanDefinitions(MapperScannerRegistrar.java:105) ~[mybatis-spring-1.3.0.jar:1.3.0] at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.lambda$loadBeanDefinitionsFromRegistrars$1(ConfigurationClassBeanDefinitionReader.java:357) ~[spring-context-5.0.5.RELEASE.jar:5.0.5.RELEASE] at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684) ~[na:1.8.0_161] at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsFromRegistrars(ConfigurationClassBeanDefinitionReader.java:356) ~[spring-context-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForConfigurationClass(ConfigurationClassBeanDefinitionReader.java:144) ~[spring-context-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitions(ConfigurationClassBeanDefinitionReader.java:117) ~[spring-context-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:328) ~[spring-context-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:233) ~[spring-context-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:273) ~[spring-context-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:93) ~[spring-context-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:694) ~[spring-context-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:532) ~[spring-context-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140) ~[spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759) [spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE] at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:395) [spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:327) [spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1255) [spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1243) [spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE] at com.stamford.b2b.App.main(App.java:22) [classes/:na] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_161] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_161] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_161] at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_161] at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) [spring-boot-devtools-2.0.1.RELEASE.jar:2.0.1.RELEASE] 我的pom.xml文件如下 <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/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.kfit</groupId> <artifactId>spring-boot-mybatis</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>jar</packaging> <name>spring-boot-mybatis</name> <url>http://maven.apache.org</url> <!-- spring boot parent节点,引入这个之后,在下面和spring boot相关的就不需要引入版本了; --> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.0.1.RELEASE</version> </parent> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <!-- 指定一下jdk的版本 ,这里我们使用jdk 1.8 ,默认是1.6 --> <java.version>1.8</java.version> </properties> <dependencies> <dependency> <groupId>dom4j</groupId> <artifactId>dom4j</artifactId> <version>1.6.1</version><!--$NO-MVN-MAN-VER$--> </dependency> <!-- web支持: 1、web mvc; 2、restful; 3、jackjson支持; 4、aop ........ --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> <exclusions> <exclusion> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> </exclusion> </exclusions> </dependency> <!-- mysql 数据库驱动. --> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> </dependency> <dependency> <groupId>com.microsoft.sqlserver</groupId> <artifactId>sqljdbc4</artifactId> <version>4.0</version> </dependency> <!-- spring-boot mybatis依赖: 请不要使用1.0.0版本,因为还不支持拦截器插件, 1.1.1 是博主写帖子时候的版本,大家使用最新版本即可 --> <dependency> <groupId>org.mybatis.spring.boot</groupId> <artifactId>mybatis-spring-boot-starter</artifactId> </dependency> <!-- MyBatis提供了拦截器接口,我们可以实现自己的拦截器, 将其作为一个plugin装入到SqlSessionFactory中。 Github上有位开发者写了一个分页插件,我觉得使用起来还可以,挺方便的。 Github项目地址: https://github.com/pagehelper/Mybatis-PageHelper --> <dependency> <groupId>com.github.pagehelper</groupId> <artifactId>pagehelper</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <optional>true</optional> <scope>true</scope> </dependency> <dependency> <groupId>com.google.code.gson</groupId> <artifactId>gson</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-configuration-processor</artifactId> <optional>true</optional> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <!-- <exclusion>                           <groupId>org.slf4j</groupId>                           <artifactId>slf4j-api</artifactId>                       </exclusion>   --> <configuration> <fork>true</fork> </configuration> </plugin> <!-- <plugin> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.7</source> <target>1.7</target> <encoding>UTF-8</encoding> <compilerArguments> <extdirs>${project.basedir}/lib</extdirs> </compilerArguments> </configuration> </plugin> --> <plugin> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.7</source> <target>1.7</target> </configuration> </plugin> </plugins> <!-- <resources> <resource> <directory>lib</directory> <targetPath>BOOT-INF/lib/</targetPath> <includes> <include>**/*.jar</include> </includes> </resource> <resource> <directory>src/main/resources</directory> <targetPath>BOOT-INF/classes/</targetPath> </resource> </resources> --> </build> <dependencyManagement> <dependencies> <dependency> <groupId>org.mybatis.spring.boot</groupId> <artifactId>mybatis-spring-boot-starter</artifactId> <version>1.1.1</version> </dependency> <dependency> <groupId>com.github.pagehelper</groupId> <artifactId>pagehelper</artifactId> <version>4.1.0</version> </dependency> </dependencies> </dependencyManagement> </project> ``` ``` 求大神指教 是怎么个问题 该怎么解决呢 跪求 ``` ``` run as Spring Boot App报错 但是run as java application 没报错

关于spring动态加载数据源切换不成功问题,请大家指导!!!

最近在做一个项目框架选用springMVC + spring + spring-data-jpa,需求要分库查询数据,按照网上的思路,利用spring的AOP编写了动态数据源加载代码。但是在运行程序时发现,一个controller方法内调用两个service查询方法,只能执行一次数据源切换,第一个方法数据源切换后,第二个查询方法不进入DynamicDataSource这个类,导致数据源没有切换回来!下面是我的代码!请大家有经验的传授一下,谢谢! ![controller层](https://img-ask.csdn.net/upload/201704/18/1492528337_771588.png) ![自定义切面](https://img-ask.csdn.net/upload/201704/18/1492528457_720147.png) ![图片说明](https://img-ask.csdn.net/upload/201704/18/1492528495_909510.png) ![动态数据源类](https://img-ask.csdn.net/upload/201704/18/1492528509_191034.png) ![applicationContext配置文件](https://img-ask.csdn.net/upload/201704/18/1492528529_387481.png) ![applicationContext配置文件](https://img-ask.csdn.net/upload/201704/18/1492528559_977561.png) ![applicationContext配置文件](https://img-ask.csdn.net/upload/201704/18/1492528585_334955.png) ![applicationContext配置文件](https://img-ask.csdn.net/upload/201704/18/1492528604_907506.png) ![applicationContext配置文件](https://img-ask.csdn.net/upload/201704/18/1492528626_569291.png)

spring OpenSessionInViewFilter无效

<p>在做一个项目,想通过spring 的OpenSessionInViewFilter配置解决session关闭的问题,可是配置了之后发现还是不成功,想问问大伙我的问题到底出在了哪里</p> <p>项目是struts2+spring2.5+hibenate3.0.</p> <p>下面是web.xml中配置的相关代码:</p> <p> &lt;filter&gt;<br>  &lt;filter-name&gt;hibernateFilter&lt;/filter-name&gt;<br>  &lt;filter-class&gt;<br>  <span style="color: #ff00ff;"> <span style="background-color: #ffffff;">org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</span></span>&lt;/filter-class&gt;<br>  &lt;init-param&gt;<br>   &lt;param-name&gt;singleSession&lt;/param-name&gt;<br>   &lt;param-value&gt;<span style="color: #ff00ff;">true</span>&lt;/param-value&gt;<br>  &lt;/init-param&gt;<br> &lt;/filter&gt;</p> <p> </p> <p>&lt;filter-mapping&gt;<br>  &lt;filter-name&gt;hibernateFilter&lt;/filter-name&gt;<br>  &lt;url-pattern<span style="color: #ff00ff;">&gt;*.action</span>&lt;/url-pattern&gt;<br> &lt;/filter-mapping&gt;</p> <p> </p> <p>下面是spring配置文件中关于事务的配置:</p> <p> </p> <p>&lt;bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate"&gt;<br>  &lt;property name="sessionFactory" ref="sessionFactory"&gt;&lt;/property&gt;<br> &lt;/bean&gt;<br> &lt;bean id="<span style="color: #ff00ff;">transactionManager</span>"<br>  class="org.springframework.orm.hibernate3.HibernateTransactionManager"&gt;<br>  &lt;property name="sessionFactory"&gt;<br>   &lt;ref local="sessionFactory" /&gt;<br>  &lt;/property&gt;<br> &lt;/bean&gt;<br> &lt;!-- 设置事务管理器 --&gt;<br> &lt;bean id="<span style="color: #ff00ff;">transactionInterceptor</span>"<br>  class="org.springframework.transaction.interceptor.TransactionInterceptor"&gt;<br>  &lt;!-- 事务拦截器需要依赖一个事务管理器 --&gt;<br>  &lt;property name="transactionManager" ref="transactionManager" /&gt;<br>  &lt;property name="transactionAttributes"&gt;<br>   &lt;!--  下面定义事务传播属性--&gt;<br>   &lt;props&gt;<br>    &lt;prop key="<span style="color: #ff00ff;">delete</span><span style="color: #ff00ff;">*</span>"&gt;PROPAGATION_REQUIRED&lt;/prop&gt;<br>    &lt;prop key="<span style="color: #ff00ff;">add</span><span style="color: #ff00ff;">*</span>"&gt;PROPAGATION_REQUIRED&lt;/prop&gt;<br>    &lt;prop key="<span style="color: #ff00ff;">update</span><span style="color: #ff00ff;">*</span>"&gt;PROPAGATION_REQUIRED&lt;/prop&gt;<br>    &lt;prop key="save<span style="color: #ff00ff;">*</span>"&gt;PROPAGATION_REQUIRED&lt;/prop&gt;<br>    &lt;prop key="<span style="color: #ff00ff;">find*</span>"&gt;PROPAGATION_REQUIRED,readOnly<br>    &lt;/prop&gt;<br>   &lt;/props&gt;<br>  &lt;/property&gt;<br> &lt;/bean&gt;<br> &lt;bean<br>  class="org.springframework.aop.framework.autoproxy.<span style="color: #ff00ff;">BeanNameAutoProxyCreator</span>"&gt;<br>  &lt;!-- 定义BeanNameAutoProxyCreator--&gt;<br>  &lt;property name="beanNames"&gt;<br>   &lt;!--  下面是所有需要自动创建事务代理的bean--&gt;<br>   &lt;value&gt;<span style="color: #ff00ff;">*Service</span>&lt;/value&gt;<br>  &lt;/property&gt;<br>  &lt;!--  下面定义BeanNameAutoProxyCreator所需的事务拦截器--&gt;<br>  &lt;property name="interceptorNames"&gt;<br>   &lt;list&gt;<br>    &lt;value&gt;transactionInterceptor&lt;/value&gt;<br>    &lt;!-- 此处可增加其他新的Interceptor --&gt;<br>   &lt;/list&gt;<br>  &lt;/property&gt;<br> &lt;/bean&gt;</p> <p> </p> <p>我在页面是想得取user类中的rose中的角度名称rname,结果显示不出--于是试着在action中进行打印该属性System.out.println(<span style="color: #ff00ff;">user.rose.rname</span>) --&gt;就指no session异常了..System.out.println(<span style="color: #ff00ff;">user.rose.<span style="color: #0000ff;"><strong>rid</strong></span></span>) --&gt;却可能显示...</p> <p>fuser = fuserService.getFuserByUser(user.getUuser());<br>     if (fuser != null) {<br>      if (Fmd5.pwdMd5(user.getUpwd()).equals(fuser.getUpwd())) {<br>      <span style="color: #ff00ff;"> System.out.println(fuser.getFrose().getRname());<br></span>       ServletActionContext.getRequest().getSession()<br>         .setAttribute("sessionUser", fuser);<br>       return SUCCESS;<br>      } else {<br>       return INPUT;<br>      }<br>     }</p> <p> </p> <p>请大伙帮忙看看,非常感谢</p>

Spring Security @PreAuthorize 问题

最近在做一个spring security的项目,遇到了一个@PreAuthorize 问题。 在interface里面我用@PreAuthorize标记了一些method, public interface PoiActionInterface { @PreAuthorize("hasRole('ROLE_ADMIN')") public String editPoi(); @PreAuthorize("hasAnyRole('ROLE_ADMIN', 'ROLE_USER')") public String listPois(); @PreAuthorize("hasRole('ROLE_ADMIN')") public String generatePoi() throws IOException, TemplateException; @PreAuthorize("hasRole('ROLE_ADMIN')") public String deletePoi(); @PreAuthorize("hasRole('ROLE_USER')") public String trc(); } 在web server启动之后,如果权限不对,会提示exception message: access denied. 但是如果权限对了时候,会出现一些奇怪的问题, public class POIAction extends ActionSupport implements PoiActionInterface { private static final long serialVersionUID = "$Id: POIAction.java 42163 2011-08-16 18:39:30Z shany@telenav.com $".hashCode(); @Autowired private TrcHibernateService trcHibernateService; @Autowired private MailService mailService; @Autowired private TemplateService templateService; private UserGeneratedPoi userPoi; private UserGeneratedPoiDetail userPoiDetail; private String timeStart; private String timeEnd; private Integer action; private String poiid; private List<UserGeneratedPoi> userPois; private static String userFirstName; public void setUserFirstName(String userFirstName) { POIAction.userFirstName = userFirstName; } public String getUserFirstName() { return userFirstName; } public void setUserPoi(UserGeneratedPoi userPoi) { this.userPoi = userPoi; } public UserGeneratedPoi getUserPoi() { return userPoi; } public String getPoiid() { return poiid; } public void setPoiid(String poiid) { this.poiid = poiid; } public void setTimeStart(String timeStart) { this.timeStart = timeStart; } public String getTimeStart() { return timeStart; } public void setTimeEnd(String timeEnd) { this.timeEnd = timeEnd; } public String getTimeEnd() { return timeEnd; } public void setUserPoiDetail(UserGeneratedPoiDetail userPoiDetail) { this.userPoiDetail = userPoiDetail; } public UserGeneratedPoiDetail getUserPoiDetail() { return userPoiDetail; } public void setAction(Integer action) { this.action = action; } public Integer getAction() { return action; } public void setUserPois(List<UserGeneratedPoi> userPois) { this.userPois = userPois; } public List<UserGeneratedPoi> getUserPois() { return userPois; } public void getFirstName() { Object obj = SecurityContextHolder.getContext().getAuthentication().getPrincipal(); POIAction.userFirstName = ((TrcUserDetail) obj).getFirstName(); } @SkipValidation @Action(value = "trc", results = { @Result(name = "success", location = "page.addpoi", type = "tiles") }) public String trc() { return SUCCESS; } @SkipValidation @Action(value = "editpoi", results = { @Result(name = "success", location = "page.editpoi", type = "tiles") }) public String editPoi() { this.userPoi = trcHibernateService.getById(UserGeneratedPoi.class, Integer.valueOf(poiid)); this.userPoiDetail = trcHibernateService.getById(UserGeneratedPoiDetail.class, Integer.valueOf(poiid)); if (userPoiDetail.getBusinessHour() != null && userPoiDetail.getBusinessHour().split(" ").length > 0) { setTimeStart(userPoiDetail.getBusinessHour().split(" ")[0]); setTimeEnd(userPoiDetail.getBusinessHour().split(" ")[1]); } return SUCCESS; } @SkipValidation @Action(value = "deletepoi", results = { @Result(name = "success", location = "page.listpois", type = "tiles") }) public String deletePoi() { this.userPoi = trcHibernateService.getById(UserGeneratedPoi.class, Integer.valueOf(poiid)); this.userPoiDetail = trcHibernateService.getById(UserGeneratedPoiDetail.class, Integer.valueOf(poiid)); trcHibernateService.delete(this.userPoiDetail); trcHibernateService.delete(this.userPoi); this.userPois = trcHibernateService.getAll(UserGeneratedPoi.class); return SUCCESS; } @SkipValidation @Action(value = "listpois", results = { @Result(name = "success", location = "page.listpois", type = "tiles") }) public String listPois() { getFirstName(); this.userPois = trcHibernateService.getAll(UserGeneratedPoi.class); return SUCCESS; } @Validations(requiredStrings = { @RequiredStringValidator(type = ValidatorType.FIELD, fieldName = "userPoi.brandName", message = "You must enter a brand name for POIs."), @RequiredStringValidator(type = ValidatorType.FIELD, fieldName = "userPoi.street1", message = "You must enter a street address for POIs."), @RequiredStringValidator(type = ValidatorType.FIELD, fieldName = "userPoi.city", message = "You must enter a city name for POIs."), @RequiredStringValidator(type = ValidatorType.FIELD, fieldName = "userPoi.state", message = "You must enter a state name for POIs."), @RequiredStringValidator(type = ValidatorType.FIELD, fieldName = "userPoi.zip", message = "You must enter a zip code for POIs.") }, stringLengthFields = { @StringLengthFieldValidator(type = ValidatorType.FIELD, trim = true, minLength = "1", maxLength = "20", fieldName = "userPoi.street1", message = "Street 1 only can have at most 20 characters") }) @Action(value = "generatepoi", results = { @Result(name = "success", location = "page.message", type = "tiles"), @Result(name = "input", location = "page.addpoi", type = "tiles") }) public String generatePoi() throws IOException, TemplateException { SecurityContext context = SecurityContextHolder.getContext(); Authentication authentication = context.getAuthentication(); User user = new User(); user.setName(authentication.getName()); user = trcHibernateService.getAll(User.class, user).get(0); userPoi.setUserByUserId(user); if (userPoi.getId() == null) { trcHibernateService.save(userPoi); } else { try { trcHibernateService.merge(userPoi); setAction(Integer.valueOf(1)); } catch (DataIntegrityViolationException dve) { addFieldError("userPoi.id", getText("dupicate poi id")); return INPUT; } } userPoiDetail.setId(userPoi.getId()); userPoiDetail.setBusinessHour(getTimeStart() + " " + getTimeEnd() + " "); if (trcHibernateService.getById(UserGeneratedPoiDetail.class, userPoi.getId()) == null) { userPoiDetail.setUserGeneratedPoi(userPoi); trcHibernateService.save(userPoiDetail); } else { try { trcHibernateService.merge(userPoiDetail); } catch (DataIntegrityViolationException dve) { addFieldError("userPoiDetail.poiId", getText("dupicate poi detail id")); return INPUT; } } if (action == null) { addActionMessage(getText("addpoi.successful", null, "")); mailService.sendMail("shany@telenav.com", "POI Added", templateService.getNewPoiNotificationText(userPoi.getId().toString())); } else { addActionMessage(getText("editpoi.successful", null, "")); } return SUCCESS; } } 所有@autowired的object全部都是null, 所以在做action的时候会有Nullpointexception出现。 Exception Stack: java.lang.NullPointerException at com.telenav.trc.action.common.POIAction.listPois(POIAction.java:172) at com.telenav.trc.action.common.POIAction$$FastClassByCGLIB$$83c14b0a.invoke(<generated>) at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204) at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:688) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150) at org.springframework.security.access.intercept.aopalliance.MethodSecurityInterceptor.invoke(MethodSecurityInterceptor.java:67) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:621) at com.telenav.trc.action.common.POIAction$$EnhancerByCGLIB$$40826733.listPois(<generated>) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:452) at com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:291) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:254) at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:176) at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) at org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:61) at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) at com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:133) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:207) at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:207) at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) at com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:190) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) at org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:75) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) at org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:94) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) at org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:243) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) at com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:100) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) at com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:141) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) at org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:270) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) at com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:145) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) at com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:171) at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) at com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:176) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) at org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) at com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:190) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) at com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:187) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:52) at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:498) at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77) at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:368) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:109) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:83) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380) at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:97) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380) at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:100) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380) at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:78) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380) at org.springframework.security.web.authentication.rememberme.RememberMeAuthenticationFilter.doFilter(RememberMeAuthenticationFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380) at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380) at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:35) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380) at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:187) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380) at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380) at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:79) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380) at org.springframework.security.web.session.ConcurrentSessionFilter.doFilter(ConcurrentSessionFilter.java:109) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380) at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:169) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:237) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:261) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:581) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447) at java.lang.Thread.run(Thread.java:662)

springboot项目下,提示shiro与aop冲突

我用的是springboot微框架。权限管控用的shiro,现在要使用aop,总是报以下错误: Error creating bean with name 'shiroFilterFactoryBean' defined in class path resource [com/zcy/salesPlatform/shiro/ShiroConfig.class]: BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration': Initialization of bean failed; nested exception is java.lang.IllegalArgumentException: Pointcut is not well-formed: expecting 'identifier' at character position 0 * com.zcy.salesPlatform.action.sell.order.*.*(..) 我的aop类: ``` package com.zcy.salesPlatform.aop; import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.annotation.Around; import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Before; import org.aspectj.lang.annotation.Pointcut; import org.springframework.stereotype.Component; @Aspect @Component public class LoggerAop { @Pointcut("* com.zcy.salesPlatform.action.sell.order.*.*(..)") public void loggerAspect(){} @Before("loggerAspect()") public void before() { System.out.println("切面before执行了"); } /*@After("loggerAspect()") public void after() { System.out.println("切面after执行了"); } @AfterReturning("loggerAspect()") public void afterReturning() { System.out.println("切面afterReturning执行了"); } @AfterThrowing("loggerAspect()") public void afterThrowing() { System.out.println("切面afterThrowing执行了"); }*/ /*@Around("loggerAspect()") public Object around(ProceedingJoinPoint thisJoinPoint){ Object obj = null; System.err.println ("切面around before执行了"); try { thisJoinPoint.proceed(); } catch (Throwable e) { e.printStackTrace (); } System.err.println ("切面around after执行了"); return obj; }*/ } ``` 我的shiro。config类: ``` package com.zcy.salesPlatform.shiro; import java.util.LinkedHashMap; import java.util.Map; import org.apache.shiro.spring.LifecycleBeanPostProcessor; import org.apache.shiro.spring.web.ShiroFilterFactoryBean; import org.apache.shiro.web.mgt.DefaultWebSecurityManager; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; /** * spring boot 集成shiro的配置 http://blog.csdn.net/catoop/article/details/50520958 * * @author luanhaibin */ @Configuration public class ShiroConfig { private static Map<String, String> filterChainDefinitionMap = new LinkedHashMap<String, String>(); @Bean(name = "shiroFilterFactoryBean") public ShiroFilterFactoryBean shiroFilterFactoryBean() { ShiroFilterFactoryBean shiroFilterFactoryBean = new ShiroFilterFactoryBean(); shiroFilterFactoryBean.setSecurityManager(securityManager()); shiroFilterFactoryBean.setLoginUrl("/user/login"); shiroFilterFactoryBean.setSuccessUrl("/menu/menuIndex"); // filterChainDefinitionMap.put("/menu/**", "authc"); // filterChainDefinitionMap.put("/personcenter/**", "authc"); filterChainDefinitionMap.put("/**", "anon"); // shiroFilterFactoryBean.setFilterChainDefinitionMap(filterChainDefinitionMap); return shiroFilterFactoryBean; } @Bean(name = "securityManager") public DefaultWebSecurityManager securityManager() { DefaultWebSecurityManager defaultWebSecurityManager = new DefaultWebSecurityManager(); defaultWebSecurityManager.setRealm(shiroRealm()); return defaultWebSecurityManager; } @Bean(name = "shiroRealm") public ShiroRealm shiroRealm() { return new ShiroRealm(); } @Bean(name = "lifecycleBeanPostProcessor") public LifecycleBeanPostProcessor lifecycleBeanPostProcessor() { // AbstractNativeSessionManager a=new AbstractNativeSessionManager(); return new LifecycleBeanPostProcessor(); } } ``` 请教各位老师各位大神,怎么破?

Spring 定时任务 在执行方法时报空指针

定时任务的xml: <bean id="autoIPV6BusinessAlarmStatisticsJob" class="org.springframework.scheduling.quartz.JobDetailBean"> <property name="jobClass"> <value>com.boco.auto.AutoIPV6BusinessAlarmStatisticsReport</value> </property> </bean> <bean id="autoIPV6BusinessAlarmStatistics" class="org.springframework.scheduling.quartz.CronTriggerBean"> <property name="jobDetail"> <ref local="autoIPV6BusinessAlarmStatisticsJob" /> </property> <property name="cronExpression"> <value>0 30 3 * * ?</value> </property> </bean> Spring注入: <bean name="/ReportCommonActionPipeRes" class="com.boco.web.struts.action.report.ReportCommonActionPipeRes" parent="baseAction"> <property name="reportCommonDao"> <ref local="reportCommonDao" /> </property> <property name="reportCommonDao_Local"> <ref local="reportCommonDao_Local" /> </property> <property name="reportCommonGroupDao"> <ref local="reportCommonGroupDao" /> </property> <property name="reportCommonService"> <ref local="reportCommonService" /> </property> <property name="linkReportDao_Local"> <ref local="linkReportDao_Local" /> </property> <property name="mysqlBaseDao"> <ref bean="mysqlBaseService" /> </property> <property name="statementManagementBean"> <ref bean="statementManagementBean" /> </property> <!-- add liuhuipeng --> <property name="vendorfaultService"> <ref local="vendorfaultService" /> </property> </bean> <bean id="vendorfaultService" class="com.boco.alarm.service.impl.VendorFaultReportServiceImpl"> <property name="reportCommonDao"> <ref local="reportCommonDao"/> </property> <property name="reportCommonDao_Local"> <ref local="reportCommonDao_Local" /> </property> <property name="alarmReportDao"> <ref local="alarmReportDao" /> </property> <property name="statementManagementBean"> <ref bean="statementManagementBean" /> </property> </bean> 定时任务: public class AutoAlarmStatisticsReport implements Job{ static Logger logger = Logger.getLogger(AutoAlarmStatisticsReport.class) ; private ReportCommonActionPipeRes pipeResAction; @Override public void execute(JobExecutionContext arg0) throws JobExecutionException { logger.info("+++进入定时任务。+++"); generateReport(); } public void generateReport(){ logger.info("modelName=AlarmStatistics"); pipeResAction = (ReportCommonActionPipeRes)StartupApp.getInstance(). getAppContext().getBean("reportpiperesource"); String modelName = "IPV6BusinessAlarmStatistics"; Date date = new Date(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); String today = sdf.format(date); this.pipeResAction.insertBusinessNEStatistics(modelName); //insertBusinessNEStatistics(modelName); } } 调用此方法: public boolean insertBusinessNEStatistics(String modelName){ boolean isOk = false; Date date = new Date(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); String createDate = sdf.format(date); SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Date datestart = new Date(); String startDateString=""; startDateString= sdf1.format(datestart); List<Map> Allist = new ArrayList(); String informixSql = statementManagementBean.getStatementByName(modelName.trim()); Map parameterMap = new HashMap(); if((null == informixSql)||informixSql.equalsIgnoreCase("no such table")){ return isOk; }else{ String[] sql_Array = informixSql.split(";"); List<Map> dataList = new ArrayList<Map>(); for(String sql : sql_Array){ if(sql != null && sql.trim().length() > 0){ if(modelName.equalsIgnoreCase("AlarmStatistics")){ String procName = "{call pro_alarm_trans_counteveryday()}"; boolean isInsertflag= false; //测试: isInsertflag = true; // try { // isInsertflag = vendorfaultService.insertIPV6AlarmCount(procName); // logger.info("++获得告警标识:++"+isInsertflag); // } catch (Exception e) { // TODO: handle exception // logger.error("error 错误的信息", e); // } if(isInsertflag == true){ try{ dataList = vendorfaultService.queyAlarm(parameterMap, sql.trim(), false); }catch(Throwable t){ logger.error("error 错误的信息", t); } }else{ return isInsertflag; } }else{ //dataList = reportCommonDao.commonQuery(sql.trim(), parameterMap); dataList = reportCommonDao.commonQuery(sql.trim(), parameterMap); } } } isOk = true; } return isOk; }

大学四年自学走来,这些私藏的实用工具/学习网站我贡献出来了

大学四年,看课本是不可能一直看课本的了,对于学习,特别是自学,善于搜索网上的一些资源来辅助,还是非常有必要的,下面我就把这几年私藏的各种资源,网站贡献出来给你们。主要有:电子书搜索、实用工具、在线视频学习网站、非视频学习网站、软件下载、面试/求职必备网站。 注意:文中提到的所有资源,文末我都给你整理好了,你们只管拿去,如果觉得不错,转发、分享就是最大的支持了。 一、电子书搜索 对于大部分程序员...

在中国程序员是青春饭吗?

今年,我也32了 ,为了不给大家误导,咨询了猎头、圈内好友,以及年过35岁的几位老程序员……舍了老脸去揭人家伤疤……希望能给大家以帮助,记得帮我点赞哦。 目录: 你以为的人生 一次又一次的伤害 猎头界的真相 如何应对互联网行业的「中年危机」 一、你以为的人生 刚入行时,拿着傲人的工资,想着好好干,以为我们的人生是这样的: 等真到了那一天,你会发现,你的人生很可能是这样的: ...

Java基础知识面试题(2020最新版)

文章目录Java概述何为编程什么是Javajdk1.5之后的三大版本JVM、JRE和JDK的关系什么是跨平台性?原理是什么Java语言有哪些特点什么是字节码?采用字节码的最大好处是什么什么是Java程序的主类?应用程序和小程序的主类有何不同?Java应用程序与小程序之间有那些差别?Java和C++的区别Oracle JDK 和 OpenJDK 的对比基础语法数据类型Java有哪些数据类型switc...

我以为我学懂了数据结构,直到看了这个导图才发现,我错了

数据结构与算法思维导图

技术大佬:我去,你写的 switch 语句也太老土了吧

昨天早上通过远程的方式 review 了两名新来同事的代码,大部分代码都写得很漂亮,严谨的同时注释也很到位,这令我非常满意。但当我看到他们当中有一个人写的 switch 语句时,还是忍不住破口大骂:“我擦,小王,你丫写的 switch 语句也太老土了吧!” 来看看小王写的代码吧,看完不要骂我装逼啊。 private static String createPlayer(PlayerTypes p...

和黑客斗争的 6 天!

互联网公司工作,很难避免不和黑客们打交道,我呆过的两家互联网公司,几乎每月每天每分钟都有黑客在公司网站上扫描。有的是寻找 Sql 注入的缺口,有的是寻找线上服务器可能存在的漏洞,大部分都...

Linux 会成为主流桌面操作系统吗?

整理 |屠敏出品 | CSDN(ID:CSDNnews)2020 年 1 月 14 日,微软正式停止了 Windows 7 系统的扩展支持,这意味着服役十年的 Windows 7,属于...

讲一个程序员如何副业月赚三万的真实故事

loonggg读完需要3分钟速读仅需 1 分钟大家好,我是你们的校长。我之前讲过,这年头,只要肯动脑,肯行动,程序员凭借自己的技术,赚钱的方式还是有很多种的。仅仅靠在公司出卖自己的劳动时...

学习总结之HTML5剑指前端(建议收藏,图文并茂)

前言学习《HTML5与CSS3权威指南》这本书很不错,学完之后我颇有感触,觉得web的世界开明了许多。这本书是需要有一定基础的web前端开发工程师。这本书主要学习HTML5和css3,看...

女程序员,为什么比男程序员少???

昨天看到一档综艺节目,讨论了两个话题:(1)中国学生的数学成绩,平均下来看,会比国外好?为什么?(2)男生的数学成绩,平均下来看,会比女生好?为什么?同时,我又联想到了一个技术圈经常讨...

搜狗输入法也在挑战国人的智商!

故事总是一个接着一个到来...上周写完《鲁大师已经彻底沦为一款垃圾流氓软件!》这篇文章之后,鲁大师的市场工作人员就找到了我,希望把这篇文章删除掉。经过一番沟通我先把这篇文章从公号中删除了...

副业收入是我做程序媛的3倍,工作外的B面人生是怎样的?

提到“程序员”,多数人脑海里首先想到的大约是:为人木讷、薪水超高、工作枯燥…… 然而,当离开工作岗位,撕去层层标签,脱下“程序员”这身外套,有的人生动又有趣,马上展现出了完全不同的A/B面人生! 不论是简单的爱好,还是正经的副业,他们都干得同样出色。偶尔,还能和程序员的特质结合,产生奇妙的“化学反应”。 @Charlotte:平日素颜示人,周末美妆博主 大家都以为程序媛也个个不修边幅,但我们也许...

MySQL数据库面试题(2020最新版)

文章目录数据库基础知识为什么要使用数据库什么是SQL?什么是MySQL?数据库三大范式是什么mysql有关权限的表都有哪几个MySQL的binlog有有几种录入格式?分别有什么区别?数据类型mysql有哪些数据类型引擎MySQL存储引擎MyISAM与InnoDB区别MyISAM索引与InnoDB索引的区别?InnoDB引擎的4大特性存储引擎选择索引什么是索引?索引有哪些优缺点?索引使用场景(重点)...

新一代神器STM32CubeMonitor介绍、下载、安装和使用教程

关注、星标公众号,不错过精彩内容作者:黄工公众号:strongerHuang最近ST官网悄悄新上线了一款比较强大的工具:STM32CubeMonitor V1.0.0。经过我研究和使用之...

记一次腾讯面试,我挂在了最熟悉不过的队列上……

腾讯后台面试,面试官问:如何自己实现队列?

如果你是老板,你会不会踢了这样的员工?

有个好朋友ZS,是技术总监,昨天问我:“有一个老下属,跟了我很多年,做事勤勤恳恳,主动性也很好。但随着公司的发展,他的进步速度,跟不上团队的步伐了,有点...

我入职阿里后,才知道原来简历这么写

私下里,有不少读者问我:“二哥,如何才能写出一份专业的技术简历呢?我总感觉自己写的简历太烂了,所以投了无数份,都石沉大海了。”说实话,我自己好多年没有写过简历了,但我认识的一个同行,他在阿里,给我说了一些他当年写简历的方法论,我感觉太牛逼了,实在是忍不住,就分享了出来,希望能够帮助到你。 01、简历的本质 作为简历的撰写者,你必须要搞清楚一点,简历的本质是什么,它就是为了来销售你的价值主张的。往深...

冒泡排序动画(基于python pygame实现)

本项目效果初始截图如下 动画见本人b站投稿:https://www.bilibili.com/video/av95491382 本项目对应github地址:https://github.com/BigShuang python版本:3.6,pygame版本:1.9.3。(python版本一致应该就没什么问题) 样例gif如下 ======================= 大爽歌作,mad

Redis核心原理与应用实践

Redis核心原理与应用实践 在很多场景下都会使用Redis,但是到了深层次的时候就了解的不是那么深刻,以至于在面试的时候经常会遇到卡壳的现象,学习知识要做到系统和深入,不要把Redis想象的过于复杂,和Mysql一样,是个读取数据的软件。 有一个理解是Redis是key value缓存服务器,更多的优点在于对value的操作更加丰富。 安装 yum install redis #yum安装 b...

现代的 “Hello, World”,可不仅仅是几行代码而已

作者 |Charles R. Martin译者 | 弯月,责编 | 夕颜头图 |付费下载自视觉中国出品 | CSDN(ID:CSDNnews)新手...

带了6个月的徒弟当了面试官,而身为高级工程师的我天天修Bug......

即将毕业的应届毕业生一枚,现在只拿到了两家offer,但最近听到一些消息,其中一个offer,我这个组据说客户很少,很有可能整组被裁掉。 想问大家: 如果我刚入职这个组就被裁了怎么办呢? 大家都是什么时候知道自己要被裁了的? 面试软技能指导: BQ/Project/Resume 试听内容: 除了刷题,还有哪些技能是拿到offer不可或缺的要素 如何提升面试软实力:简历, 行为面试,沟通能...

!大部分程序员只会写3年代码

如果世界上都是这种不思进取的软件公司,那别说大部分程序员只会写 3 年代码,恐怕就没有程序员这种职业。

离职半年了,老东家又发 offer,回不回?

有小伙伴问松哥这个问题,他在上海某公司,在离职了几个月后,前公司的领导联系到他,希望他能够返聘回去,他很纠结要不要回去? 俗话说好马不吃回头草,但是这个小伙伴既然感到纠结了,我觉得至少说明了两个问题:1.曾经的公司还不错;2.现在的日子也不是很如意。否则应该就不会纠结了。 老实说,松哥之前也有过类似的经历,今天就来和小伙伴们聊聊回头草到底吃不吃。 首先一个基本观点,就是离职了也没必要和老东家弄的苦...

2020阿里全球数学大赛:3万名高手、4道题、2天2夜未交卷

阿里巴巴全球数学竞赛( Alibaba Global Mathematics Competition)由马云发起,由中国科学技术协会、阿里巴巴基金会、阿里巴巴达摩院共同举办。大赛不设报名门槛,全世界爱好数学的人都可参与,不论是否出身数学专业、是否投身数学研究。 2020年阿里巴巴达摩院邀请北京大学、剑桥大学、浙江大学等高校的顶尖数学教师组建了出题组。中科院院士、美国艺术与科学院院士、北京国际数学...

为什么你不想学习?只想玩?人是如何一步一步废掉的

不知道是不是只有我这样子,还是你们也有过类似的经历。 上学的时候总有很多光辉历史,学年名列前茅,或者单科目大佬,但是虽然慢慢地长大了,你开始懈怠了,开始废掉了。。。 什么?你说不知道具体的情况是怎么样的? 我来告诉你: 你常常潜意识里或者心理觉得,自己真正的生活或者奋斗还没有开始。总是幻想着自己还拥有大把时间,还有无限的可能,自己还能逆风翻盘,只不是自己还没开始罢了,自己以后肯定会变得特别厉害...

HTTP与HTTPS的区别

面试官问HTTP与HTTPS的区别,我这样回答让他竖起大拇指!

程序员毕业去大公司好还是小公司好?

虽然大公司并不是人人都能进,但我仍建议还未毕业的同学,尽力地通过校招向大公司挤,但凡挤进去,你这一生会容易很多。 大公司哪里好?没能进大公司怎么办?答案都在这里了,记得帮我点赞哦。 目录: 技术氛围 内部晋升与跳槽 啥也没学会,公司倒闭了? 不同的人脉圈,注定会有不同的结果 没能去大厂怎么办? 一、技术氛围 纵观整个程序员技术领域,哪个在行业有所名气的大牛,不是在大厂? 而且众所...

男生更看重女生的身材脸蛋,还是思想?

往往,我们看不进去大段大段的逻辑。深刻的哲理,往往短而精悍,一阵见血。问:产品经理挺漂亮的,有点心动,但不知道合不合得来。男生更看重女生的身材脸蛋,还是...

程序员为什么千万不要瞎努力?

本文作者用对比非常鲜明的两个开发团队的故事,讲解了敏捷开发之道 —— 如果你的团队缺乏统一标准的环境,那么即使勤劳努力,不仅会极其耗时而且成果甚微,使用...

为什么程序员做外包会被瞧不起?

二哥,有个事想询问下您的意见,您觉得应届生值得去外包吗?公司虽然挺大的,中xx,但待遇感觉挺低,马上要报到,挺纠结的。

立即提问
相关内容推荐