cdi @Startup注释的@PostConstruct方法未调用

时间:2019-03-10 09:35:14

标签: annotations cdi startup

为什么启动时未调用方法getUsers()?

@Singleton
@Startup 
public class DBStartup {

@Inject
private UserService userService;

@PostConstruct
public void getUsers(){
    userService.getAllUsers();
}
}

应用程序配置:

<?xml version="1.0" encoding="UTF-8"?>
<application xmlns="http://java.sun.com/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_6.xsd"
         version="6">

</application>

Beans.xml:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
                       http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd" bean-discovery-mode="all">

控制台日志:

E:\Users\maxhe\Downloads\payara-5.184\payara5\glassfish\bin\asadmin.bat start-domain --debug domain1
"C:\Program Files\Java\jdk1.8.0_181\bin\java.exe" -Dfile.encoding=windows-1252 -classpath "C:\Program Files\JetBrains\IntelliJ IDEA 2018.1.6\lib\idea_rt.jar" com.intellij.rt.execution.CommandLineWrapper C:\Users\maxhe\AppData\Local\Temp\idea_classpath com.intellij.javaee.oss.process.JavaeeProcess 53695 com.intellij.javaee.oss.glassfish.agent.Glassfish31Agent
[2019-03-10 01:26:15,397] Artifact kwetter: Waiting for server connection to start artifact deployment...
Detected server admin port: 4848
Detected server http port: 8080
Attempting to start domain1.... Please look at the server log for more details.....
Connected to the target VM, address: '127.0.0.1:9009', transport: 'socket'
Connected to server
[2019-03-10 01:26:28,115] Artifact kwetter: Artifact is being deployed, please wait...
[2019-03-10 01:26:29,511] Artifact kwetter: Artifact is deployed successfully
[2019-03-10 01:26:29,511] Artifact kwetter: Deploy took 1.396 milliseconds

它认为应用程序配置内部有问题

0 个答案:

没有答案