Uruchamianie web apki

0

Cześć! Jako zadanie stażowe dostałem napisanie prostego CRUDa z frontem. Wszystko spoko, baza podpięta, testy napisane, front ułomny ale jest tylko teraz moje pytanie - jest napisane: Wymagamy aby aplikacja po ściągnięciu jej na lokalny komputer uruchomiła się bez błędów. Jak to wygląda od ich strony? Pobierają kod z repo, odpalają jakieś IDE i wtedy sobie testują czy wszystko gra? Druga sprawa: jak wspomniałem mam podpiętą bazę danych mysql. U mnie to fajnie działa bo mam pod siebie skonfigurowany plik application.properties. Czy oni sobie pozmieniają co tam trzeba czy stwierdzą - **uj, nie działa, następny! Nie chciałbym żeby na starcie odpaść przez taką głupotę, jeśli się uda to będzie to moje pierwsze doświadczenie komercyjne, na którym mi bardzo zależy ;p

0

Uruchomienie bez błędów nie tyczy się konfiguracji, tym się akurat nie martw, kwestia jest tylko to by twój projekt się budował a nie żeby ktoś musiał grzebać w kodzie bo zrobiłeś błędy. Jestem przekonany że poradzą sobie z podpięciem bazy a jeżeli nie to może i lepiej dla ciebie :)

0

Jeżeli testujesz apkę na bazie odpalonej u siebie lokalnie to oczywiste jest, że gdy rekruter będzie próbował ją odpalić u siebie to dostanie ekran z błędami. To co możesz zrobić to: wrzucić aplikacje razem z bazą w kontenery i uruchamiać oba jedną komendą docker run, przesiąść się na bazę in-memory albo dać instrukcję uruchamiania w README.md w repo.

1

Baza in memory i fat jar może być dobrą opcją.

0

Na miejscu takiej osoby co sprawdza chyba szlag by mnie trafił, jakbym musiał robić coś więcej poza mvn cośtam-run czy prawoklik->Run w IntelliJ, zwłaszcza jakbym miał tych zadań sporo :) Po prostu zrób, żeby odpalało się od razu, najlepiej sprawdź też na innym kompie.

Jeśli możesz zrezygnować z MySQL, to rozsądnym wydaje się H2 w pamięci/pliku (jak kolega wyżej zauważył), albo przerzucić się w ogóle na jakieś in-memory repository albo plik json/csv gdzieś w folderze projektu.
Jeśli koniecznie musisz mieć MySQL, to odpal na jakiś czas jakiś bieda-vps z MySQL albo jakiś bieda-hosting PHP z dostępem MySQL z zewnątrz. Hasła, trudno, wbić trzeba do kodu.

0

sqlitle?

0

Dzięki za odpowiedzi ;) Od razu się spytam tutaj żeby nie tworzyć nowego tematu - mam plik data.sql, który użytkownikowi tworzonemu w tym skrypcie nadaję rolę admina a wszystkim innym użytkownikom, którzy się rejestrują, rolę zwykłego usera.

insert into user_role(role, description) VALUES ("ROLE_USER", "default role for user");
insert into user_role(role, description) values ("ROLE_ADMIN", "role for admin");
insert into user (email, first_name, last_name, password) values ("[email protected]","admin","admin","{bcrypt}$2a$10$PG/5c58jyJ03AJKZDouS5uWQAp.Xq1fzZfXy2hQ1PdvTbkcLm/Lj.");
insert into user_roles(user_id, roles_id) values ("1","2");

Gdy korzystałem z mysql wszystko fajnie śmigało ale gdy korzystam teraz z H2 to wywala błąd związany z przydzielaniem roli :/ Korzystając z H2 muszę jakoś inaczej zdefiniować to przydzielanie?

Logi błędu:

! 2019-06-06 1548.217 INFO 1496 --- [ restartedMain] com.skoczek.demo.DemoApplication : Starting DemoApplication on SKOQ with PID 1496 (C:\Users\Kuba\Desktop\biblioteka\kind-of-library\target\classes started by Kuba in C:\Users\Kuba\Desktop\biblioteka\kind-of-library)
2019-06-06 1548.217 INFO 1496 --- [ restartedMain] com.skoczek.demo.DemoApplication : No active profile set, falling back to default profiles: default
2019-06-06 1548.280 INFO 1496 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
2019-06-06 1548.280 INFO 1496 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
2019-06-06 1549.323 INFO 1496 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data repositories in DEFAULT mode.
2019-06-06 1549.386 INFO 1496 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 63ms. Found 2 repository interfaces.
2019-06-06 1549.730 INFO 1496 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$c004fa5f] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-06-06 1550.058 INFO 1496 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2019-06-06 1550.073 INFO 1496 --- [ restartedMain] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2019-06-06 1550.073 INFO 1496 --- [ restartedMain] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.16]
2019-06-06 1550.089 INFO 1496 --- [ restartedMain] o.a.catalina.core.AprLifecycleListener : The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [C:\Program Files\Java\jdk1.8.0_171\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files (x86)\AMD\ATI.ACE\Core-Static;C:\Program Files (x86)\Skype\Phone;C:\WINDOWS\System32\OpenSSH;D:\Git\cmd;D:\Git\mingw64\bin;D:\Git\usr\bin;C:\Users\Kuba\AppData\Local\Microsoft\WindowsApps;;.]
2019-06-06 1550.183 INFO 1496 --- [ restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2019-06-06 1550.183 INFO 1496 --- [ restartedMain] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1903 ms
2019-06-06 1550.339 INFO 1496 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2019-06-06 1550.479 INFO 1496 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2019-06-06 1550.526 INFO 1496 --- [ restartedMain] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [
name: default
...]
2019-06-06 1550.573 INFO 1496 --- [ restartedMain] org.hibernate.Version : HHH000412: Hibernate Core {5.3.7.Final}
2019-06-06 1550.573 INFO 1496 --- [ restartedMain] org.hibernate.cfg.Environment : HHH000206: hibernate.properties not found
2019-06-06 1550.683 INFO 1496 --- [ restartedMain] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.0.4.Final}
2019-06-06 1550.807 INFO 1496 --- [ restartedMain] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.H2Dialect
2019-06-06 1551.323 INFO 1496 --- [ restartedMain] o.h.t.schema.internal.SchemaCreatorImpl : HHH000476: Executing import script 'org.hibernate.tool.schema.internal.exec.ScriptSourceInputNonExistentImpl@2abee90d'
2019-06-06 1551.323 INFO 1496 --- [ restartedMain] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2019-06-06 1551.354 INFO 1496 --- [ restartedMain] o.s.b.d.a.OptionalLiveReloadServer : LiveReload server is running on port 35729
2019-06-06 1551.370 WARN 1496 --- [ restartedMain] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Initialization of bean failed; nested exception is org.springframework.jdbc.datasource.init.ScriptStatementFailedException: Failed to execute SQL script statement #1 of URL [file:/C:/Users/Kuba/Desktop/biblioteka/kind-of-library/target/classes/data.sql]: insert into user_role(role, description) VALUES ("ROLE_USER", "default role for user"); nested exception is org.h2.jdbc.JdbcSQLSyntaxErrorException: Kolumna "ROLE_USER" nie istnieje
Column "ROLE_USER" not found; SQL statement:
insert into user_role(role, description) VALUES ("ROLE_USER", "default role for user") [42122-199]
2019-06-06 1551.370 INFO 1496 --- [ restartedMain] o.s.b.f.support.DisposableBeanAdapter : Invocation of destroy method failed on bean with name 'inMemoryDatabaseShutdownExecutor': org.h2.jdbc.JdbcSQLNonTransientConnectionException: Baza danych jest już zamknięta (aby zablokować samoczynne zamykanie podczas zamknięcia VM dodaj ";DB_CLOSE_ON_EXIT=FALSE" do URL bazy danych)
Database is already closed (to disable automatic closing at VM shutdown, add ";DB_CLOSE_ON_EXIT=FALSE" to the db URL) [90121-199]
2019-06-06 1551.370 INFO 1496 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated...
2019-06-06 1551.370 INFO 1496 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown completed.
2019-06-06 1551.370 INFO 1496 --- [ restartedMain] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2019-06-06 1551.370 INFO 1496 --- [ restartedMain] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2019-06-06 1551.385 ERROR 1496 --- [ restartedMain] o.s.boot.SpringApplication : Application run failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Initialization of bean failed; nested exception is org.springframework.jdbc.datasource.init.ScriptStatementFailedException: Failed to execute SQL script statement #1 of URL [file:/C:/Users/Kuba/Desktop/biblioteka/kind-of-library/target/classes/data.sql]: insert into user_role(role, description) VALUES ("ROLE_USER", "default role for user"); nested exception is org.h2.jdbc.JdbcSQLSyntaxErrorException: Kolumna "ROLE_USER" nie istnieje
Column "ROLE_USER" not found; SQL statement:
insert into user_role(role, description) VALUES ("ROLE_USER", "default role for user") [42122-199]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:601) ~[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515) ~[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320) ~[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318) ~[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1105) ~[spring-context-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:867) ~[spring-context-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549) ~[spring-context-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:142) ~[spring-boot-2.1.3.RELEASE.jar:2.1.3.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:775) [spring-boot-2.1.3.RELEASE.jar:2.1.3.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) [spring-boot-2.1.3.RELEASE.jar:2.1.3.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:316) [spring-boot-2.1.3.RELEASE.jar:2.1.3.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1260) [spring-boot-2.1.3.RELEASE.jar:2.1.3.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1248) [spring-boot-2.1.3.RELEASE.jar:2.1.3.RELEASE]
at com.skoczek.demo.DemoApplication.main(DemoApplication.java:17) [classes/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_171]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_171]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_171]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_171]
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) [spring-boot-devtools-2.1.3.RELEASE.jar:2.1.3.RELEASE]
Caused by: org.springframework.jdbc.datasource.init.ScriptStatementFailedException: Failed to execute SQL script statement #1 of URL [file:/C:/Users/Kuba/Desktop/biblioteka/kind-of-library/target/classes/data.sql]: insert into user_role(role, description) VALUES ("ROLE_USER", "default role for user"); nested exception is org.h2.jdbc.JdbcSQLSyntaxErrorException: Kolumna "ROLE_USER" nie istnieje
Column "ROLE_USER" not found; SQL statement:
insert into user_role(role, description) VALUES ("ROLE_USER", "default role for user") [42122-199]
at org.springframework.jdbc.datasource.init.ScriptUtils.executeSqlScript(ScriptUtils.java:509) ~[spring-jdbc-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.jdbc.datasource.init.ResourceDatabasePopulator.populate(ResourceDatabasePopulator.java:238) ~[spring-jdbc-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.jdbc.datasource.init.DatabasePopulatorUtils.execute(DatabasePopulatorUtils.java:48) ~[spring-jdbc-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.boot.autoconfigure.jdbc.DataSourceInitializer.runScripts(DataSourceInitializer.java:210) ~[spring-boot-autoconfigure-2.1.3.RELEASE.jar:2.1.3.RELEASE]
at org.springframework.boot.autoconfigure.jdbc.DataSourceInitializer.initSchema(DataSourceInitializer.java:123) ~[spring-boot-autoconfigure-2.1.3.RELEASE.jar:2.1.3.RELEASE]
at org.springframework.boot.autoconfigure.jdbc.DataSourceInitializerInvoker.onApplicationEvent(DataSourceInitializerInvoker.java:93) ~[spring-boot-autoconfigure-2.1.3.RELEASE.jar:2.1.3.RELEASE]
at org.springframework.boot.autoconfigure.jdbc.DataSourceInitializerInvoker.onApplicationEvent(DataSourceInitializerInvoker.java:37) ~[spring-boot-autoconfigure-2.1.3.RELEASE.jar:2.1.3.RELEASE]
at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172) ~[spring-context-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165) ~[spring-context-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139) ~[spring-context-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:402) ~[spring-context-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:359) ~[spring-context-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.boot.autoconfigure.orm.jpa.DataSourceInitializedPublisher.publishEventIfRequired(DataSourceInitializedPublisher.java:98) ~[spring-boot-autoconfigure-2.1.3.RELEASE.jar:2.1.3.RELEASE]
at org.springframework.boot.autoconfigure.orm.jpa.DataSourceInitializedPublisher.postProcessAfterInitialization(DataSourceInitializedPublisher.java:88) ~[spring-boot-autoconfigure-2.1.3.RELEASE.jar:2.1.3.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:429) ~[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1766) ~[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:593) ~[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]
... 20 common frames omitted
Caused by: org.h2.jdbc.JdbcSQLSyntaxErrorException: Kolumna "ROLE_USER" nie istnieje
Column "ROLE_USER" not found; SQL statement:
insert into user_role(role, description) VALUES ("ROLE_USER", "default role for user") [42122-199]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:451) ~[h2-1.4.199.jar:1.4.199]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:427) ~[h2-1.4.199.jar:1.4.199]
at org.h2.message.DbException.get(DbException.java:205) ~[h2-1.4.199.jar:1.4.199]
at org.h2.message.DbException.get(DbException.java:181) ~[h2-1.4.199.jar:1.4.199]
at org.h2.expression.ExpressionColumn.getColumnException(ExpressionColumn.java:176) ~[h2-1.4.199.jar:1.4.199]
at org.h2.expression.ExpressionColumn.optimize(ExpressionColumn.java:158) ~[h2-1.4.199.jar:1.4.199]
at org.h2.command.dml.Insert.prepare(Insert.java:322) ~[h2-1.4.199.jar:1.4.199]
at org.h2.command.Parser.prepareCommand(Parser.java:689) ~[h2-1.4.199.jar:1.4.199]
at org.h2.engine.Session.prepareLocal(Session.java:627) ~[h2-1.4.199.jar:1.4.199]
at org.h2.engine.Session.prepareCommand(Session.java:565) ~[h2-1.4.199.jar:1.4.199]
at org.h2.jdbc.JdbcConnection.prepareCommand(JdbcConnection.java:1292) ~[h2-1.4.199.jar:1.4.199]
at org.h2.jdbc.JdbcStatement.executeInternal(JdbcStatement.java:217) ~[h2-1.4.199.jar:1.4.199]
at org.h2.jdbc.JdbcStatement.execute(JdbcStatement.java:205) ~[h2-1.4.199.jar:1.4.199]
at com.zaxxer.hikari.pool.ProxyStatement.execute(ProxyStatement.java:95) ~[HikariCP-3.2.0.jar:na]
at com.zaxxer.hikari.pool.HikariProxyStatement.execute(HikariProxyStatement.java) ~[HikariCP-3.2.0.jar:na]
at org.springframework.jdbc.datasource.init.ScriptUtils.executeSqlScript(ScriptUtils.java:488) ~[spring-jdbc-5.1.5.RELEASE.jar:5.1.5.RELEASE]
... 36 common frames omitted

Process finished with exit code 0

1 użytkowników online, w tym zalogowanych: 0, gości: 1