当前位置: 首页 > 知识库问答 >
问题:

如何在websphere liberty 8.5中设置spring.profiles.active

孙志
2023-03-14

为什么当我尝试用jvm.options文件启动Websphere时,我会得到错误“unrecognited option:-spring.profiles.active=development”?我正在遵循http://www-01.ibm.com/support/docview.wss?uid=swg21596474中提供的步骤。

实际上,我想使用添加到Eclipse服务器视图中的Websphere Liberty配置文件,就像使用Tomcat一样。在Tomcat8中,我只是在catalina.properties中添加了“spring.profiles.active=development”,其效果与我开始使用“mvn...-dspring.profiles.active=development”相同。

我将我的问题视为开发人员的主题,因为我想知道如何利用@Profile启动Websphere Liberty配置文件。

请务必理解我使用的是Websphere Liberty,这意味着我没有Websphere Admin Console,因此,如果有人在Websphere Admin Console屏幕中提供步骤,它将毫无价值。

我添加了一个图像来显示我的Eclipse服务器视图,以及我在哪里添加了jvm.options文件,该文件只包含-spring.profiles.active=development。

只有当我尝试用这样的jvm.otions启动服务器时,才会出现错误。如果我取出文件,服务器将启动,但很明显,当我添加应用程序时,@profile将不会被考虑在内。

整个错误:

Error: Could not create the Java Virtual Machine.

Error: A fatal exception has occurred. Program will exit.

Picked up JAVA_TOOL_OPTIONS: -agentlib:jvmhook

Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0

Unrecognized option: -spring.profiles.active=development

附言。我不认为这与我的问题有关,顺便说一句,整个应用程序可以在https://github.com/jhades/spring-mvc-angularjs-sample-app中找到

***编辑1

在我按照建议在“-”后面添加“d”之后,我可以启动服务器(这在Tomcat中是不同的,因为在Tomcat中必须避免“d”)。顺便说一下,当我将应用程序部署到WAS Liberty时,我根本没有看到@profile生效。我在整个Websphere日志下面添加了内容,但我没有看到通常在Tomcat中看到的长日志描述。由于我面临一个与上下文路径相关的额外错误(请参见附加的新图像),除了查看欢迎页面之外,我无法测试应用程序,但我几乎可以肯定@profile在某种程度上被忽略了,因为日志似乎没有考虑到它。

********************************************************************************

product = WebSphere Application Server 8.5.5.9 (wlp-1.0.12.cl50920160227-1523)

wlp.install.dir = C:/Users/my_user/WasWebDownloadedFromEclipse/

java.home = C:\Program Files\Java\jdk1.8.0_65\jre

java.version = 1.8.0_65

java.runtime = Java(TM) SE Runtime Environment (1.8.0_65-b17)

os = Windows 7 (6.1; amd64) (en_US)

process = 6780@GH-VDIKCISV252

********************************************************************************

[7/7/16 16:13:04:151 CDT] 00000001 com.ibm.ws.kernel.launch.internal.FrameworkManager           A CWWKE0001I: The server srvFromDefaultLink has been launched.

[7/7/16 16:13:04:175 CDT] 00000001 com.ibm.ws.kernel.launch.internal.FrameworkManager           A CWWKE0100I: This product is licensed for development, and limited production use. The full license terms can be viewed here: https://public.dhe.ibm.com/ibmdl/export/pub/software/websphere/wasdev/license/base_ilan/ilan/8.5.5.9/lafiles/en.html

[7/7/16 16:13:07:531 CDT] 00000001 com.ibm.ws.kernel.launch.internal.FrameworkManager           I CWWKE0002I: The kernel started after 3.998 seconds

[7/7/16 16:13:07:727 CDT] 00000017 com.ibm.ws.kernel.feature.internal.FeatureManager            I CWWKF0007I: Feature update started.

[7/7/16 16:13:09:941 CDT] 00000010 com.ibm.ws.security.ready.internal.SecurityReadyServiceImpl  I CWWKS0007I: The security service is starting...

[7/7/16 16:13:11:591 CDT] 00000018 com.ibm.ws.security.token.ltpa.internal.LTPAKeyCreator       I CWWKS4105I: LTPA configuration is ready after 0.406 seconds.

[7/7/16 16:13:12:599 CDT] 00000010 com.ibm.ws.app.manager.internal.monitor.DropinMonitor        A CWWKZ0058I: Monitoring dropins for applications.

[7/7/16 16:13:13:904 CDT] 0000001d com.ibm.ws.tcpchannel.internal.TCPChannel                    I CWWKO0219I: TCP Channel defaultHttpEndpoint has been started and is now listening for requests on host 127.0.0.1  (IPv4: 127.0.0.1) port 8080.

[7/7/16 16:13:17:499 CDT] 00000010 com.ibm.ws.cache.ServerCache                                 I DYNA1001I: WebSphere Dynamic Cache instance named baseCache initialized successfully.

[7/7/16 16:13:17:502 CDT] 00000010 com.ibm.ws.cache.ServerCache                                 I DYNA1071I: The cache provider default is being used.

[7/7/16 16:13:17:503 CDT] 00000010 com.ibm.ws.cache.CacheServiceImpl                            I DYNA1056I: Dynamic Cache (object cache) initialized successfully.

[7/7/16 16:13:19:346 CDT] 00000017 com.ibm.ws.kernel.feature.internal.FeatureManager            A CWWKF0012I: The server installed the following features: [jsp-2.3, ejbLite-3.2, managedBeans-1.0, jsf-2.2, beanValidation-1.1, servlet-3.1, ssl-1.0, jndi-1.0, localConnector-1.0, jsonp-1.0, appSecurity-2.0, jdbc-4.1, jaxrs-2.0, jaxrsClient-2.0, el-3.0, json-1.0, cdi-1.2, distributedMap-1.0, webProfile-7.0, websocket-1.1, jpa-2.1].

[7/7/16 16:13:19:347 CDT] 00000017 com.ibm.ws.kernel.feature.internal.FeatureManager            I CWWKF0008I: Feature update completed in 11.807 seconds.

[7/7/16 16:13:19:348 CDT] 00000017 com.ibm.ws.kernel.feature.internal.FeatureManager            A CWWKF0011I: The server srvFromDefaultLink is ready to run a smarter planet.

[7/7/16 16:13:44:452 CDT] 00000017 com.ibm.ws.config.xml.internal.ConfigRefresher               A CWWKG0016I: Starting server configuration update.

[7/7/16 16:13:44:605 CDT] 00000018 com.ibm.ws.app.manager.AppMessageHelper                      W CWWKZ0014W: The application spring-mvc-angularjs-sample-app-master could not be started as it could not be found at location spring-mvc-angularjs-sample-app-master.war.

[7/7/16 16:13:44:606 CDT] 00000017 com.ibm.ws.config.xml.internal.ConfigRefresher               A CWWKG0017I: The server configuration was successfully updated in 0.311 seconds.

[7/7/16 16:13:45:227 CDT] 00000017 com.ibm.ws.app.manager.AppMessageHelper                      I CWWKZ0018I: Starting application spring-mvc-angularjs-sample-app-master.

[7/7/16 16:13:53:746 CDT] 00000017 org.jboss.weld.Version                                       I WELD-000900: SNAPSHOT

[7/7/16 16:14:15:269 CDT] 00000018 com.ibm.ws.app.manager.AppMessageHelper                      A CWWKZ0022W: Application spring-mvc-angularjs-sample-app-master has not started in 30.042 seconds.

[7/7/16 16:14:25:297 CDT] 00000017 com.ibm.ws.webcontainer.osgi.webapp.WebGroup                 I SRVE0169I: Loading Web Module: Archetype Created Web Application.

[7/7/16 16:14:25:302 CDT] 00000017 com.ibm.ws.webcontainer                                      I SRVE0250I: Web Module Archetype Created Web Application has been bound to default_host.

[7/7/16 16:14:25:304 CDT] 00000017 com.ibm.ws.http.internal.VirtualHostImpl                     A CWWKT0016I: Web application available (default_host): http://localhost:8080/calories-tracker/

[7/7/16 16:14:25:309 CDT] 00000017 com.ibm.ws.app.manager.AppMessageHelper                      A CWWKZ0001I: Application spring-mvc-angularjs-sample-app-master started in 40.082 seconds.

[7/7/16 16:16:53:905 CDT] 0000002b com.ibm.ws.session.WASSessionCore                            I SESN8501I: The session manager did not find a persistent storage location; HttpSession objects will be stored in the local application server's memory.

[7/7/16 16:16:53:912 CDT] 0000002b com.ibm.ws.session.WASSessionCore                            I SESN0176I: A new session context will be created for application key default_host/calories-tracker

[7/7/16 16:16:54:017 CDT] 0000002b com.ibm.ws.util                                              I SESN0172I: The session manager is using the Java default SecureRandom implementation for session ID generation.

[7/7/16 16:16:54:089 CDT] 0000002b com.ibm.ws.jsp                                               I JSPG8502I: The value of the JSP attribute jdkSourceLevel is "15".

[7/7/16 16:16:54:483 CDT] 0000002b com.ibm.ws.cache.CacheServiceImpl                            I DYNA1056I: Dynamic Cache (object cache) initialized successfully.

[7/7/16 16:16:55:462 CDT] 0000002b com.ibm.ws.webcontainer.webapp                               I SRVE0292I: Servlet Message - [spring-mvc-angularjs-sample-app-master]:.Spring WebApplicationInitializers detected on classpath: [calories.tracker.config.SecurityWebApplicationInitializer@23cbd857, calories.tracker.config.WebAppInitializer@7c711eb2]

[7/7/16 16:16:55:606 CDT] 0000002b com.ibm.ws.webcontainer.webapp                               I SRVE0292I: Servlet Message - [spring-mvc-angularjs-sample-app-master]:.Initializing Spring root WebApplicationContext

[7/7/16 16:16:55:607 CDT] 0000002b org.springframework.web.context.ContextLoader                I Root WebApplicationContext: initialization started

[7/7/16 16:16:55:678 CDT] 0000002b rk.web.context.support.AnnotationConfigWebApplicationContext I Refreshing Root WebApplicationContext: startup date [Thu Jul 07 16:16:55 CDT 2016]; root of context hierarchy

[7/7/16 16:16:55:708 CDT] 0000002b rk.web.context.support.AnnotationConfigWebApplicationContext I Registering annotated classes: [class calories.tracker.config.root.RootContextConfig,class calories.tracker.config.root.DevelopmentConfiguration,class calories.tracker.config.root.TestConfiguration,class calories.tracker.config.root.AppSecurityConfig]

[7/7/16 16:16:56:578 CDT] 0000002b eans.factory.annotation.AutowiredAnnotationBeanPostProcessor I JSR-330 'javax.inject.Inject' annotation found and supported for autowiring

[7/7/16 16:16:56:838 CDT] 0000002b org.springframework.jdbc.datasource.DriverManagerDataSource  I Loaded JDBC driver: org.postgresql.Driver

[7/7/16 16:16:56:958 CDT] 0000002b ringframework.orm.jpa.LocalContainerEntityManagerFactoryBean I Building JPA container EntityManagerFactory for persistence unit 'default'

[7/7/16 16:17:02:203 CDT] 0000002b org.springframework.security.web.DefaultSecurityFilterChain  I Creating filter chain: org.springframework.security.web.util.matcher.AnyRequestMatcher@1, [org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@297728f1, org.springframework.security.web.context.SecurityContextPersistenceFilter@724560fb, org.springframework.security.web.header.HeaderWriterFilter@d397b67, org.springframework.security.web.csrf.CsrfFilter@f62a487, com.allanditzel.springframework.security.web.csrf.CsrfTokenResponseHeaderBindingFilter@10fd6c23, org.springframework.security.web.authentication.logout.LogoutFilter@5ed9a45a, org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter@625bbf32, org.springframework.security.web.authentication.www.BasicAuthenticationFilter@266bef7, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@343dbd9e, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@6a796e81, org.springframework.security.web.authentication.AnonymousAuthenticationFilter@198ef120, org.springframework.security.web.session.SessionManagementFilter@79951250, org.springframework.security.web.access.ExceptionTranslationFilter@558e68b7, org.springframework.security.web.access.intercept.FilterSecurityInterceptor@639c2328]

[7/7/16 16:17:02:250 CDT] 0000002b org.springframework.web.context.ContextLoader                I Root WebApplicationContext: initialization completed in 6629 ms

[7/7/16 16:17:02:294 CDT] 0000002b com.ibm.ws.webcontainer.webapp                               I SRVE0292I: Servlet Message - [spring-mvc-angularjs-sample-app-master]:.Initializing Spring FrameworkServlet 'dispatcher'

[7/7/16 16:17:02:294 CDT] 0000002b org.springframework.web.servlet.DispatcherServlet            I FrameworkServlet 'dispatcher': initialization started

[7/7/16 16:17:02:321 CDT] 0000002b rk.web.context.support.AnnotationConfigWebApplicationContext I Refreshing WebApplicationContext for namespace 'dispatcher-servlet': startup date [Thu Jul 07 16:17:02 CDT 2016]; parent: Root WebApplicationContext

[7/7/16 16:17:02:329 CDT] 0000002b rk.web.context.support.AnnotationConfigWebApplicationContext I Registering annotated classes: [class calories.tracker.config.servlet.ServletContextConfig]

[7/7/16 16:17:02:541 CDT] 0000002b eans.factory.annotation.AutowiredAnnotationBeanPostProcessor I JSR-330 'javax.inject.Inject' annotation found and supported for autowiring

[7/7/16 16:17:03:584 CDT] 0000002b b.servlet.mvc.method.annotation.RequestMappingHandlerMapping I Mapped "{[/lifecycle],methods=[POST],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public void calories.tracker.app.controllers.LifeCycleController.createLifeCycle(calories.tracker.app.dto.LifeCycleDTO)

[7/7/16 16:17:03:586 CDT] 0000002b b.servlet.mvc.method.annotation.RequestMappingHandlerMapping I Mapped "{[/meal],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public calories.tracker.app.dto.MealsDTO calories.tracker.app.controllers.MealController.searchMealsByDate(java.security.Principal,java.util.Date,java.util.Date,java.util.Date,java.util.Date,java.lang.Integer)

[7/7/16 16:17:03:587 CDT] 0000002b b.servlet.mvc.method.annotation.RequestMappingHandlerMapping I Mapped "{[/meal],methods=[POST],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.util.List<calories.tracker.app.dto.MealDTO> calories.tracker.app.controllers.MealController.saveMeals(java.security.Principal,java.util.List<calories.tracker.app.dto.MealDTO>)

[7/7/16 16:17:03:588 CDT] 0000002b b.servlet.mvc.method.annotation.RequestMappingHandlerMapping I Mapped "{[/meal],methods=[DELETE],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public void calories.tracker.app.controllers.MealController.deleteMeals(java.util.List<java.lang.Long>)

[7/7/16 16:17:03:592 CDT] 0000002b b.servlet.mvc.method.annotation.RequestMappingHandlerMapping I Mapped "{[/user],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public calories.tracker.app.dto.UserInfoDTO calories.tracker.app.controllers.UserController.getUserInfo(java.security.Principal)

[7/7/16 16:17:03:593 CDT] 0000002b b.servlet.mvc.method.annotation.RequestMappingHandlerMapping I Mapped "{[/user],methods=[PUT],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public void calories.tracker.app.controllers.UserController.updateUserMaxCaloriesPerDay(java.security.Principal,java.lang.Long)

[7/7/16 16:17:03:597 CDT] 0000002b b.servlet.mvc.method.annotation.RequestMappingHandlerMapping I Mapped "{[/user],methods=[POST],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public void calories.tracker.app.controllers.UserController.createUser(calories.tracker.app.dto.NewUserDTO)

[7/7/16 16:17:03:656 CDT] 0000002b .springframework.web.servlet.handler.SimpleUrlHandlerMapping I Mapped URL path [/resources/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]

[7/7/16 16:17:03:953 CDT] 0000002b b.servlet.mvc.method.annotation.RequestMappingHandlerAdapter I Looking for @ControllerAdvice: WebApplicationContext for namespace 'dispatcher-servlet': startup date [Thu Jul 07 16:17:02 CDT 2016]; parent: Root WebApplicationContext

[7/7/16 16:17:04:235 CDT] 0000002b org.springframework.web.servlet.DispatcherServlet            I FrameworkServlet 'dispatcher': initialization completed in 1940 ms

[7/7/16 16:17:04:235 CDT] 0000002b com.ibm.ws.webcontainer.servlet                              I SRVE0242I: [spring-mvc-angularjs-sample-app-master] [/calories-tracker] [dispatcher]: Initialization successful.

可能忽略了配置文件(“开发”)

@Configuration
@Profile("development")
@EnableTransactionManagement
public class DevelopmentConfiguration {
    @Bean(name = "datasource")
    public DriverManagerDataSource dataSource() {
...
    @Bean(name = "entityManagerFactory")
    public LocalContainerEntityManagerFactoryBean entityManagerFactory(DriverManagerDataSource dataSource) 
...

共有1个答案

唐珂
2023-03-14

>

  • 通过命令行传递给java的JVM参数应该以-d开头

    -Dspring.profiles.active=development
    

    通过JVM.options传递的JVM参数应该以-d开头

    通过catalina.properties传递的JVM参数不需要前缀-d

  •  类似资料:
    • 问题内容: 我正在尝试使用JavaFX中的WebView入门,但是当尝试打开W​​ebView时,我收到以下所示的错误,我该如何解决此问题? 问题答案: 尝试运行WebView时遇到任何错误时,请确保您的VM选项包含模块javafx.web。 虚拟机选项: 在IntelliJ中,您可以通过转到IDE右上方的“编辑配置”按钮来访问VM选项。

    • 问题内容: 我已经使用数据库中的SQL数据库开发了一个窗口服务,该数据库中的记录已满,因此查询执行需要很多时间,而默认命令超时是30S,但我想将其增加到120S。 但是我的应用程序中有很多方法,因此我想从APP.config文件中进行设置,这样它将适用于应用程序级别,任何人都可以告诉我如何实现此目标 谢谢 问题答案: 实现此目的的最简单方法是在类似以下内容的地方添加新条目: 然后,创建一个将填充值

    • 问题内容: 我有一个模型: 如何编写基于类的视图,该视图创建新的模型实例并将外键设置为? 问题答案: 我通过覆盖方法解决了这个问题。下面是详细说明的样式: 但是我们可以简短地说(感谢dowjones123),在docs中提到了这种情况。

    • 问题内容: 我试着把这2行 在我的根.htaccess文件中,但这给我带来“内部服务器错误”消息… php5正在服务器上运行, 我无权访问php.ini,因此我认为htaccess是我唯一的机会。 你能告诉我哪里错了吗? 提前致谢 问题答案: 是正确的。 您将必须与您的托管服务商联系-有些不允许您更改php.ini中的值

    • 我希望从服务器加载数据并显示到我的应用程序中(

    • 我想将JBoss5中的JVM选项设置为: 我怎么能这么做? ...22:12:32,015错误[ProfileServiceBootstrap]未能加载配置文件:org.jboss.deployers.spi.deploymentException.rethrowsdeploymentException.restrowasdeploymentException(deploymentExceptio

    • 我正在尝试使用Cordova进行应用程序开发。目前我主要关注Android系统。我正在尝试运行。它运行,在一长串包之后,它说“构建成功”,但最后它还说 我用自制的。下面是命令行上的命令输出:

    • 我想在不同的情况下芳香地改变一些约束。 声明来自情节提要的约束: 这是我的代码,我想在其中更改约束: 但是约束仍然没有改变。 这是我的手机ForRowAt func: 提前感谢您的帮助!